Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions BitFaster.Caching/Lfu/ConcurrentLfuCore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -717,7 +717,7 @@ private void EvictEntries()
EvictFromMain(candidate);
}

private LfuNode<K, V> EvictFromWindow()
private LfuNode<K, V>? EvictFromWindow()
{
LfuNode<K, V>? first = null;

Expand All @@ -732,17 +732,17 @@ private LfuNode<K, V> EvictFromWindow()
node.Position = Position.Probation;
}

return first!;
return first;
}

private ref struct EvictIterator
{
private readonly CmSketch<K> sketch;
public LfuNode<K, V> node;
public LfuNode<K, V>? node;
public int freq;

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public EvictIterator(CmSketch<K> sketch, LfuNode<K, V> node)
public EvictIterator(CmSketch<K> sketch, LfuNode<K, V>? node)
{
this.sketch = sketch;
this.node = node;
Expand All @@ -752,7 +752,7 @@ public EvictIterator(CmSketch<K> sketch, LfuNode<K, V> node)
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Next()
{
node = node.Next;
node = node!.Next;

if (node != null)
{
Expand All @@ -761,7 +761,7 @@ public void Next()
}
}

private void EvictFromMain(LfuNode<K, V> candidateNode)
private void EvictFromMain(LfuNode<K, V>? candidateNode)
{
var victim = new EvictIterator(this.cmSketch, this.probationLru.First); // victims are LRU position in probation
var candidate = new EvictIterator(this.cmSketch, candidateNode);
Expand Down
Loading