mirror of
https://github.com/MoleskiCoder/EightBitNet.git
synced 2025-08-07 20:25:28 +00:00
Improve symbol/span access speeds
This commit is contained in:
@@ -15,8 +15,7 @@
|
||||
public bool Parsed { get; private set; }
|
||||
|
||||
// Section -> Unique ID list of dictionary entries
|
||||
// Being sorted allows us to verify IDs as they arrive
|
||||
private readonly Dictionary<string, SortedDictionary<int, Dictionary<string, string>>> _parsed = [];
|
||||
private readonly Dictionary<string, List<Dictionary<string, string>>> _parsed = [];
|
||||
|
||||
private Version? _version;
|
||||
private Information? _information;
|
||||
@@ -271,14 +270,17 @@
|
||||
|
||||
Debug.Assert(into.Count == 0);
|
||||
into.Capacity = parsed.Count;
|
||||
foreach (var (id, information) in parsed)
|
||||
for (var id = 0; id < parsed.Count; ++id)
|
||||
{
|
||||
Debug.Assert(into.Count == id);
|
||||
var entry = (T?)Activator.CreateInstance(typeof(T), this);
|
||||
Debug.Assert(entry != null);
|
||||
var information = parsed[id];
|
||||
entry.Parse(information);
|
||||
into.Add(entry);
|
||||
}
|
||||
Debug.Assert(into.Count == parsed.Count);
|
||||
|
||||
this.VerifyInformationCount(key, into.Count);
|
||||
}
|
||||
|
||||
@@ -400,10 +402,7 @@
|
||||
throw new InvalidOperationException($"Invalid symbol file format (No count information available for {section})");
|
||||
}
|
||||
|
||||
if (!section.TryAdd(identifier, dictionary))
|
||||
{
|
||||
throw new InvalidOperationException($"Invalid symbol file format (definition id ({identifier}) has clashed)");
|
||||
}
|
||||
section.Add(dictionary);
|
||||
}
|
||||
|
||||
private static Dictionary<string, string> BuildDictionary(string[] parts)
|
||||
|
@@ -16,7 +16,7 @@
|
||||
public string? Type => this.MaybeTakeString("type");
|
||||
|
||||
[SectionProperty("size")]
|
||||
public int Size => this.TakeInteger("size");
|
||||
public int Size { get; private set; }
|
||||
|
||||
[SectionReference("parent")]
|
||||
public Scope? Parent => this.MaybeTakeParentReference();
|
||||
@@ -40,6 +40,12 @@
|
||||
|
||||
[SectionReferences("span")]
|
||||
public List<Span> Spans => this.TakeSpanReferences();
|
||||
|
||||
public override void Parse(IDictionary<string, string> entries)
|
||||
{
|
||||
base.Parse(entries);
|
||||
this.Size = this.TakeInteger("size");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -25,13 +25,19 @@
|
||||
public List<Line> References => this.TakeLineReferences("ref"); // Guess
|
||||
|
||||
[SectionProperty("val", hexadecimal: true)]
|
||||
public int Value => this.TakeInteger("val");
|
||||
public int Value { get; private set; }
|
||||
|
||||
[SectionReference("seg")]
|
||||
public Symbols.Segment Segment => this.TakeSegmentReference();
|
||||
|
||||
[SectionEnumeration("type")]
|
||||
public string Type => this.TakeString("type");
|
||||
|
||||
public override void Parse(IDictionary<string, string> entries)
|
||||
{
|
||||
base.Parse(entries);
|
||||
this.Value = this.TakeInteger("val");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user