This is an automated email from the ASF dual-hosted git repository.

paulirwin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/lucenenet.git


The following commit(s) were added to refs/heads/master by this push:
     new 627fccc84 Use concrete ConcurrentHashSet instead of abstraction for 
performance (#960)
627fccc84 is described below

commit 627fccc840ad74fa51bfff897373f5a5b450c661
Author: Shannon Deminick <[email protected]>
AuthorDate: Fri Sep 20 15:34:08 2024 -0600

    Use concrete ConcurrentHashSet instead of abstraction for performance (#960)
    
    * Use concrete ConcurrentHashSet instead of abstraction for performance
    
    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
---
 src/Lucene.Net/Search/ReferenceManager.cs | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/Lucene.Net/Search/ReferenceManager.cs 
b/src/Lucene.Net/Search/ReferenceManager.cs
index ee9c2f34b..ccfb109f4 100644
--- a/src/Lucene.Net/Search/ReferenceManager.cs
+++ b/src/Lucene.Net/Search/ReferenceManager.cs
@@ -56,7 +56,7 @@ namespace Lucene.Net.Search
 
         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()
         {
@@ -367,7 +367,7 @@ namespace Lucene.Net.Search
             {
                 throw new ArgumentNullException(nameof(listener), "Listener 
cannot be null"); // LUCENENET specific - changed from IllegalArgumentException 
to ArgumentNullException (.NET convention)
             }
-            refreshListeners.Remove(listener);
+            refreshListeners.TryRemove(listener);
         }
     }
 
@@ -396,4 +396,4 @@ namespace Lucene.Net.Search
             void AfterRefresh(bool didRefresh);
         }
     }
-}
\ No newline at end of file
+}

Reply via email to