make sure standardstrategy is inlined
huge performance benefits. no seriously. quite spectacular
This commit is contained in:
parent
a54b17167e
commit
c363cae136
2 changed files with 34 additions and 12 deletions
|
|
@ -35,3 +35,19 @@ public readonly struct StandardStrategy<K> : IKeyStrategy<K>
|
|||
return _comparer.Compare(x, y);
|
||||
}
|
||||
}
|
||||
public readonly struct StandardStrategy2<K, TComparer> : IKeyStrategy<K>
|
||||
where TComparer : struct, IComparer<K>
|
||||
{
|
||||
private readonly TComparer _comparer;
|
||||
|
||||
public StandardStrategy2(TComparer comparer) => _comparer = comparer;
|
||||
|
||||
public bool UsesPrefixes => false;
|
||||
public bool UseBinarySearch => true;
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public int Compare(K x, K y) => _comparer.Compare(x, y);
|
||||
|
||||
public long GetPrefix(K key) => 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue