Only keep column names in SaneTsvRecord

We don't need to reference the parent
This commit is contained in:
Nathan McRae 2024-02-19 21:03:48 -08:00
parent 221f4eeff5
commit 0b7a920096

View File

@ -238,7 +238,7 @@ public class SaneTsv
comment = currentComment.ToString();
currentComment.Clear();
}
parsed.Records.Add(new SaneTsvRecord(parsed, ParseCurrentRecord(parsed, fields, line), comment, line));
parsed.Records.Add(new SaneTsvRecord(parsed.ColumnNames, ParseCurrentRecord(parsed, fields, line), comment, line));
fields.Clear();
}
@ -298,7 +298,7 @@ public class SaneTsv
comment = currentComment.ToString();
currentComment.Clear();
}
parsed.Records.Add(new SaneTsvRecord(parsed, ParseCurrentRecord(parsed, fields, line), comment, line));
parsed.Records.Add(new SaneTsvRecord(parsed.ColumnNames, ParseCurrentRecord(parsed, fields, line), comment, line));
fields.Clear();
}
@ -925,18 +925,18 @@ public class SaneTsv
public class SaneTsvRecord
{
public SaneTsv Parent { get; }
public string[] ColumnNames { get; }
public string Comment { get; }
public object[] Fields { get; }
public int Line { get; }
public object this[string columnName] => Fields[Array.IndexOf(Parent.ColumnNames, columnName)];
public object this[string columnName] => Fields[Array.IndexOf(ColumnNames, columnName)];
public object this[int columnIndex] => Fields[columnIndex];
public SaneTsvRecord(SaneTsv parent, object[] fields, string comment, int line)
public SaneTsvRecord(string[] columnNames, object[] fields, string comment, int line)
{
Parent = parent;
ColumnNames = columnNames;
Fields = fields;
Comment = comment;
Line = line;