diff --git a/M6502/M6502.Symbols/IdentifiableSection.cs b/M6502/M6502.Symbols/IdentifiableSection.cs index e425016..d792ebe 100644 --- a/M6502/M6502.Symbols/IdentifiableSection.cs +++ b/M6502/M6502.Symbols/IdentifiableSection.cs @@ -38,16 +38,17 @@ protected List TakeReferences(string key, List? from) where T : IdentifiableSection { ArgumentNullException.ThrowIfNull(from); - List returned = []; var ids = this.MaybeTakeMultiple(key); if (ids != null) { + var returned = new List(ids.Count); foreach (var id in ids) { returned.Add(from[id]); } + return returned; } - return returned; + return []; } #endregion diff --git a/M6502/M6502.Symbols/Parser.cs b/M6502/M6502.Symbols/Parser.cs index 555ff5d..499ab7d 100644 --- a/M6502/M6502.Symbols/Parser.cs +++ b/M6502/M6502.Symbols/Parser.cs @@ -300,6 +300,8 @@ { throw new InvalidOperationException($"Debugging section: '{key}' is unavailable"); } + Debug.Assert(into.Count == 0); + into.Capacity = parsed.Count; foreach (var element in parsed) { var id = element.Key; diff --git a/M6502/M6502.Symbols/Section.cs b/M6502/M6502.Symbols/Section.cs index a64b4a3..325fc7b 100644 --- a/M6502/M6502.Symbols/Section.cs +++ b/M6502/M6502.Symbols/Section.cs @@ -89,8 +89,8 @@ protected static List ExtractCompoundString(string value) => new(value.Split('+')); protected static List ExtractCompoundInteger(string value) { - var returned = new List(); var elements = ExtractCompoundString(value); + var returned = new List(elements.Count); foreach (var element in elements) { returned.Add(ExtractInteger(element));