diff --git a/src/AsmResolver/Collections/RefList.cs b/src/AsmResolver/Collections/RefList.cs index b37971f8f..4fa091140 100644 --- a/src/AsmResolver/Collections/RefList.cs +++ b/src/AsmResolver/Collections/RefList.cs @@ -59,7 +59,7 @@ public int Capacity if (value < _count) throw new ArgumentException("Capacity must be equal or larger than the current number of elements in the list."); - EnsureEnoughCapacity(value); + EnsureCapacity(value); IncrementVersion(); } } @@ -141,7 +141,7 @@ public ref T GetElementRef(int index, out int version) /// The element. public void Add(in T item) { - EnsureEnoughCapacity(_count + 1); + EnsureCapacity(_count + 1); _items[_count] = item; _count++; IncrementVersion(); @@ -208,7 +208,7 @@ public bool Remove(in T item) /// The element to insert. public void Insert(int index, in T item) { - EnsureEnoughCapacity(_count + 1); + EnsureCapacity(_count + 1); if (index < _count) Array.Copy(_items, index, _items, index + 1, _count - index); @@ -260,9 +260,9 @@ private void AssertIsValidIndex(int index) throw new IndexOutOfRangeException(); } - private void EnsureEnoughCapacity(int requiredCount) + private void EnsureCapacity(int requiredCount) { - if (_items.Length >= requiredCount) + if (_items.Length >= requiredCount) return; int newCapacity = _items.Length == 0 ? 1 : _items.Length * 2;