Skip to content

Commit

Permalink
* Revert the changes to TryInsert() introduced by dotnet/coreclr#17096
Browse files Browse the repository at this point in the history
…completely, which only showed modest size improvement

* Removing the _version increment from Clear() entirely to bring it in line with the behavior in Remove() and to keep size gains

[tfs-changeset: 1714543]

Signed-off-by: dotnet-bot <[email protected]>


Commit migrated from dotnet/coreclr@a00a6ea
  • Loading branch information
dotnet-bot authored and jkotas committed Sep 19, 2018
1 parent c75277f commit ddcdb97
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,6 @@ public void Clear()
_freeCount = 0;
Array.Clear(_entries, 0, count);
}
_version++;
}

public bool ContainsKey(TKey key)
Expand Down Expand Up @@ -476,7 +475,6 @@ private bool TryInsert(TKey key, TValue value, InsertionBehavior behavior)
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.key);
}

_version++;
if (_buckets == null)
{
Initialize(0);
Expand Down Expand Up @@ -511,6 +509,7 @@ private bool TryInsert(TKey key, TValue value, InsertionBehavior behavior)
if (behavior == InsertionBehavior.OverwriteExisting)
{
entries[i].value = value;
_version++;
return true;
}

Expand Down Expand Up @@ -552,6 +551,7 @@ private bool TryInsert(TKey key, TValue value, InsertionBehavior behavior)
if (behavior == InsertionBehavior.OverwriteExisting)
{
entries[i].value = value;
_version++;
return true;
}

Expand Down Expand Up @@ -590,6 +590,7 @@ private bool TryInsert(TKey key, TValue value, InsertionBehavior behavior)
if (behavior == InsertionBehavior.OverwriteExisting)
{
entries[i].value = value;
_version++;
return true;
}

Expand Down Expand Up @@ -647,6 +648,7 @@ private bool TryInsert(TKey key, TValue value, InsertionBehavior behavior)
entry.value = value;
// Value in _buckets is 1-based
bucket = index + 1;
_version++;

// Value types never rehash
if (default(TKey) == null && collisionCount > HashHelpers.HashCollisionThreshold && comparer is NonRandomizedStringEqualityComparer)
Expand Down

0 comments on commit ddcdb97

Please sign in to comment.