paulirwin commented on code in PR #938:
URL: https://github.com/apache/lucenenet/pull/938#discussion_r1713951955


##########
src/Lucene.Net/Support/ConcurrentHashSet.cs:
##########
@@ -74,9 +74,9 @@ public int Count
                 {
                     AcquireAllLocks(ref acquiredLocks);
 
-                    for (var i = 0; i < _tables.CountPerLock.Length; i++)
+                    foreach (var t in _tables.CountPerLock)

Review Comment:
   ConcurrentDictionary does use foreach: 
https://github.com/dotnet/runtime/blob/c4624d0a3c91fb1496b0910b22c9d9fc197247e8/src/libraries/System.Collections.Concurrent/src/System/Collections/Concurrent/ConcurrentDictionary.cs#L1180-L1189
   
   Given that Microsoft does use foreach in ConcurrentDictionary (now, 
anyways), I have demonstrated that it is faster, and that this aligns with 
Microsoft's guidance (while acknowledging that they point out that LINQ Sum can 
be even faster due to vectorization, not to mention simpler code), can we leave 
this as a foreach?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@lucenenet.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to