Small optimizations
This commit is contained in:
1 parent
e0daccdc1a
commit
974b1da873
1 file changed
+7
-9
@@ -39,7 +39,10 @@ public sealed class BTree<TKey, TValue>()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (_nodeCount == 0)
|
||||||
|
{
|
||||||
EnsureRoot();
|
EnsureRoot();
|
||||||
|
}
|
||||||
|
|
||||||
Node[] nodes = _nodes;
|
Node[] nodes = _nodes;
|
||||||
if (smallCount > 0)
|
if (smallCount > 0)
|
||||||
@@ -116,24 +119,19 @@ public sealed class BTree<TKey, TValue>()
|
|||||||
: 0u;
|
: 0u;
|
||||||
}
|
}
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
|
||||||
private void EnsureRoot()
|
private void EnsureRoot()
|
||||||
{
|
{
|
||||||
if (_nodeCount != 0)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
_nodes = new Node[DefaultCapacity];
|
_nodes = new Node[DefaultCapacity];
|
||||||
_nodes[0] = new Node();
|
_nodes[0] = new Node();
|
||||||
_nodeCount = 1;
|
_nodeCount = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveOptimization)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
||||||
private void InsertIntoTree(uint hash, TKey key, TValue value, int currentCount)
|
private void InsertIntoTree(uint hash, TKey key, TValue value, int currentCount)
|
||||||
{
|
{
|
||||||
var nodes = _nodes;
|
Node[]? nodes = _nodes;
|
||||||
var currentIndex = 0;
|
int currentIndex = 0;
|
||||||
int depth = currentCount < ShallowTreeThreshold ? ShallowHashByteCount : HashByteCount;
|
int depth = currentCount < ShallowTreeThreshold ? ShallowHashByteCount : HashByteCount;
|
||||||
|
|
||||||
int nodeCount = _nodeCount;
|
int nodeCount = _nodeCount;
|
||||||
|
|||||||
Reference in new issue
Block a user