Skip to content

Commit

Permalink
Use concrete ConcurrentHashSet instead of abstraction for performance
Browse files Browse the repository at this point in the history
Calling into an interface when its not necessary will result in poorer performance because the JIT needs to do some type analysis. When it is a concrete type, this is avoided. Since this is an internal field there's no reason to use the abstracted type. 

See https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca1859
  • Loading branch information
Shazwazza authored Sep 20, 2024
1 parent 0d7bba7 commit 1e1599a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Lucene.Net/Search/ReferenceManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ protected G Current

private readonly ReentrantLock refreshLock = new ReentrantLock();

private readonly ISet<ReferenceManager.IRefreshListener> refreshListeners = new ConcurrentHashSet<ReferenceManager.IRefreshListener>();
private readonly ConcurrentHashSet<ReferenceManager.IRefreshListener> refreshListeners = new ConcurrentHashSet<ReferenceManager.IRefreshListener>();

private void EnsureOpen()
{
Expand Down Expand Up @@ -396,4 +396,4 @@ public interface IRefreshListener
void AfterRefresh(bool didRefresh);
}
}
}
}

0 comments on commit 1e1599a

Please sign in to comment.