Tweak ImmutableDictionary.TryGetValue to improve throughput (dotnet/corefx#35759)
authorStephen Toub <stoub@microsoft.com>
Tue, 5 Mar 2019 19:55:56 +0000 (11:55 -0800)
committerGitHub <noreply@github.com>
Tue, 5 Mar 2019 19:55:56 +0000 (11:55 -0800)
commit91538c4d55d88d2b36e50c1310015c7dc02bc71a
tree616f46e862f5a6fca353d637db36012f996b0e75
parent06397983d3c9c94aaf2d577534209d8af8cea476
Tweak ImmutableDictionary.TryGetValue to improve throughput (dotnet/corefx#35759)

* Avoid recursive calls in SortedInt32KeyNode.Search

* Compare first key directly in HashBucket

* Seal a few internal types that have virtual overrides or interface implementations

* Avoid extra level of indirection with Search

Now that it's no longer recursive, we can just inline it and build the caller's decisions right into it.

Commit migrated from https://github.com/dotnet/corefx/commit/8c54cd84f98c553b75356c69d2c8f5a4029717bc
src/libraries/System.Collections.Immutable/src/System/Collections/Immutable/DictionaryEnumerator.cs
src/libraries/System.Collections.Immutable/src/System/Collections/Immutable/ImmutableDictionary_2.Comparers.cs
src/libraries/System.Collections.Immutable/src/System/Collections/Immutable/ImmutableDictionary_2.HashBucket.cs
src/libraries/System.Collections.Immutable/src/System/Collections/Immutable/ImmutableDictionary_2.MutationInput.cs
src/libraries/System.Collections.Immutable/src/System/Collections/Immutable/ImmutableDictionary_2.cs
src/libraries/System.Collections.Immutable/src/System/Collections/Immutable/KeysOrValuesCollectionAccessor.cs
src/libraries/System.Collections.Immutable/src/System/Collections/Immutable/SortedInt32KeyNode.cs