make sure standardstrategy is inlined

huge performance benefits. no seriously.  quite spectacular
This commit is contained in:
Linus Björnstam 2026-04-24 19:42:53 +02:00
parent a54b17167e
commit c363cae136
2 changed files with 34 additions and 12 deletions

View file

@ -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;
}