Skip to content

Commit

Permalink
Version increment for TrimExcess and EnsureCapacity (#31007)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidkaya committed Jul 13, 2018
1 parent 041f919 commit 92d8f19
Showing 1 changed file with 2 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -972,6 +972,7 @@ public int EnsureCapacity(int capacity)
int currentCapacity = _entries == null ? 0 : _entries.Length;
if (currentCapacity >= capacity)
return currentCapacity;
_version++;
if (_buckets == null)
return Initialize(capacity);
int newSize = HashHelpers.GetPrime(capacity);
Expand Down Expand Up @@ -1011,6 +1012,7 @@ public void TrimExcess(int capacity)
return;

int oldCount = _count;
_version++;
Initialize(newSize);
Entry[] entries = _entries;
int[] buckets = _buckets;
Expand Down

0 comments on commit 92d8f19

Please sign in to comment.