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

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

commit bce60152a9ffe05983322e495e7001b186588e0c
Author: Shad Storhaug <s...@shadstorhaug.com>
AuthorDate: Fri Nov 22 22:30:44 2019 +0700

    Lucene.Net.Support.Collections: Factored out AddAll(ISet<T>, 
IEnumerable<T>) in favor of set.UnionWith()
---
 src/Lucene.Net/Index/DocumentsWriterPerThread.cs |  4 ++--
 src/Lucene.Net/Index/ParallelAtomicReader.cs     |  4 ++--
 src/Lucene.Net/Index/ParallelCompositeReader.cs  |  6 +++---
 src/Lucene.Net/Index/SegmentCommitInfo.cs        |  2 +-
 src/Lucene.Net/Support/Collections.cs            | 10 ----------
 5 files changed, 8 insertions(+), 18 deletions(-)

diff --git a/src/Lucene.Net/Index/DocumentsWriterPerThread.cs 
b/src/Lucene.Net/Index/DocumentsWriterPerThread.cs
index aef08d0..c80cefd 100644
--- a/src/Lucene.Net/Index/DocumentsWriterPerThread.cs
+++ b/src/Lucene.Net/Index/DocumentsWriterPerThread.cs
@@ -184,7 +184,7 @@ namespace Lucene.Net.Index
                 }
 
                 pendingUpdates.Clear();
-                Collections.AddAll(createdFiles, directory.CreatedFiles);
+                createdFiles.UnionWith(directory.CreatedFiles);
             }
             finally
             {
@@ -632,7 +632,7 @@ namespace Lucene.Net.Index
             {
                 if (indexWriterConfig.UseCompoundFile)
                 {
-                    Collections.AddAll(filesToDelete, 
IndexWriter.CreateCompoundFile(infoStream, directory, CheckAbort.NONE, 
newSegment.Info, context));
+                    
filesToDelete.UnionWith(IndexWriter.CreateCompoundFile(infoStream, directory, 
CheckAbort.NONE, newSegment.Info, context));
                     newSegment.Info.UseCompoundFile = true;
                 }
 
diff --git a/src/Lucene.Net/Index/ParallelAtomicReader.cs 
b/src/Lucene.Net/Index/ParallelAtomicReader.cs
index e35cb84..9770579 100644
--- a/src/Lucene.Net/Index/ParallelAtomicReader.cs
+++ b/src/Lucene.Net/Index/ParallelAtomicReader.cs
@@ -108,8 +108,8 @@ namespace Lucene.Net.Index
                 this.maxDoc = this.numDocs = 0;
                 this.hasDeletions = false;
             }
-            Collections.AddAll(completeReaderSet, this.parallelReaders);
-            Collections.AddAll(completeReaderSet, this.storedFieldsReaders);
+            completeReaderSet.UnionWith(this.parallelReaders);
+            completeReaderSet.UnionWith(this.storedFieldsReaders);
 
             // check compatibility:
             foreach (AtomicReader reader in completeReaderSet)
diff --git a/src/Lucene.Net/Index/ParallelCompositeReader.cs 
b/src/Lucene.Net/Index/ParallelCompositeReader.cs
index a5ed16f..26aaa93 100644
--- a/src/Lucene.Net/Index/ParallelCompositeReader.cs
+++ b/src/Lucene.Net/Index/ParallelCompositeReader.cs
@@ -78,8 +78,8 @@ namespace Lucene.Net.Index
             : base(PrepareSubReaders(readers, storedFieldReaders))
         {
             this.closeSubReaders = closeSubReaders;
-            Collections.AddAll(completeReaderSet, readers);
-            Collections.AddAll(completeReaderSet, storedFieldReaders);
+            completeReaderSet.UnionWith(readers);
+            completeReaderSet.UnionWith(storedFieldReaders);
             // update ref-counts (like MultiReader):
             if (!closeSubReaders)
             {
@@ -89,7 +89,7 @@ namespace Lucene.Net.Index
                 }
             }
             // finally add our own synthetic readers, so we close or decRef 
them, too (it does not matter what we do)
-            Collections.AddAll(completeReaderSet, GetSequentialSubReaders());
+            completeReaderSet.UnionWith(GetSequentialSubReaders());
         }
 
         private static IndexReader[] PrepareSubReaders(CompositeReader[] 
readers, CompositeReader[] storedFieldsReaders)
diff --git a/src/Lucene.Net/Index/SegmentCommitInfo.cs 
b/src/Lucene.Net/Index/SegmentCommitInfo.cs
index 9c71b5f..c76451e 100644
--- a/src/Lucene.Net/Index/SegmentCommitInfo.cs
+++ b/src/Lucene.Net/Index/SegmentCommitInfo.cs
@@ -186,7 +186,7 @@ namespace Lucene.Net.Index
             // Must separately add any field updates files
             foreach (ISet<string> updateFiles in genUpdatesFiles.Values)
             {
-                Collections.AddAll(files, updateFiles);
+                files.UnionWith(updateFiles);
             }
 
             return files;
diff --git a/src/Lucene.Net/Support/Collections.cs 
b/src/Lucene.Net/Support/Collections.cs
index 76adb23..00faebe 100644
--- a/src/Lucene.Net/Support/Collections.cs
+++ b/src/Lucene.Net/Support/Collections.cs
@@ -29,16 +29,6 @@ namespace Lucene.Net.Support
 
     public static class Collections
     {
-        public static bool AddAll<T>(ISet<T> set, IEnumerable<T> elements)
-        {
-            bool result = false;
-            foreach (T element in elements)
-            {
-                result |= set.Add(element);
-            }
-            return result;
-        }
-
         public static IList<T> EmptyList<T>()
         {
             return (IList<T>)Enumerable.Empty<T>();

Reply via email to