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


##########
src/Lucene.Net/Support/ConcurrentHashSet.cs:
##########
@@ -753,7 +753,16 @@ private void CopyToItems(T[] array, int index)
 
         public void ExceptWith(IEnumerable<T> other)
         {
-            throw new NotImplementedException();
+            if (ReferenceEquals(this, other))
+            {
+                Clear();
+                return;
+            }
+
+            foreach (var item in other)
+            {
+                TryRemove(item);

Review Comment:
   Agreed, I did add the `other == this` (just with a `ReferenceEquals` call 
instead) optimization. (btw, for posterity, your link goes to `IntersectWith`, 
but the `ExceptWith` code is right below it.) I didn't add the `Count` 
optimization because that needs to block the entire set and I wasn't yet 
prepared to implement a full blocking implementation once I considered the 
concerns above. And as noted above, it's probably a moot point if we end up 
removing the use of our `ConcurrentHashSet` because of the race condition 
issues I noted. I'm now suspicious of other uses of this type btw.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to