mirror of
https://github.com/MoleskiCoder/EightBitNet.git
synced 2026-03-11 05:41:49 +00:00
use a pre-determined list capacity, if available
This commit is contained in:
@@ -38,16 +38,17 @@
|
||||
protected List<T> TakeReferences<T>(string key, List<T>? from) where T : IdentifiableSection
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(from);
|
||||
List<T> returned = [];
|
||||
var ids = this.MaybeTakeMultiple(key);
|
||||
if (ids != null)
|
||||
{
|
||||
var returned = new List<T>(ids.Count);
|
||||
foreach (var id in ids)
|
||||
{
|
||||
returned.Add(from[id]);
|
||||
}
|
||||
return returned;
|
||||
}
|
||||
return returned;
|
||||
return [];
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -89,8 +89,8 @@
|
||||
protected static List<string> ExtractCompoundString(string value) => new(value.Split('+'));
|
||||
protected static List<int> ExtractCompoundInteger(string value)
|
||||
{
|
||||
var returned = new List<int>();
|
||||
var elements = ExtractCompoundString(value);
|
||||
var returned = new List<int>(elements.Count);
|
||||
foreach (var element in elements)
|
||||
{
|
||||
returned.Add(ExtractInteger(element));
|
||||
|
||||
Reference in New Issue
Block a user