lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nightowl...@apache.org
Subject [lucenenet] 03/03: Lucene.Net.Benchmark: Use RetainAll() for better efficiency
Date Sat, 24 Jul 2021 19:04:32 GMT
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 a147f676acc3526056a10dec08ad2bb029267d03
Author: Shad Storhaug <shad@shadstorhaug.com>
AuthorDate: Fri Jul 23 13:07:27 2021 +0700

    Lucene.Net.Benchmark: Use RetainAll() for better efficiency
---
 .../ByTask/Tasks/SearchTravRetHighlightTask.cs                   | 9 +--------
 .../ByTask/Tasks/SearchTravRetVectorHighlightTask.cs             | 9 +--------
 2 files changed, 2 insertions(+), 16 deletions(-)

diff --git a/src/Lucene.Net.Benchmark/ByTask/Tasks/SearchTravRetHighlightTask.cs b/src/Lucene.Net.Benchmark/ByTask/Tasks/SearchTravRetHighlightTask.cs
index 19a5af5..1f54d9b 100644
--- a/src/Lucene.Net.Benchmark/ByTask/Tasks/SearchTravRetHighlightTask.cs
+++ b/src/Lucene.Net.Benchmark/ByTask/Tasks/SearchTravRetHighlightTask.cs
@@ -122,14 +122,7 @@ namespace Lucene.Net.Benchmarks.ByTask.Tasks
             //if stored is false, then result will be empty, in which case just get all the
param fields
             if (m_paramFields.Count > 0 && result.Count > 0)
             {
-                //result.RetainAll(paramFields);
-                var toRemove = new List<string>();
-                foreach (var e in result)
-                {
-                    if (!m_paramFields.Contains(e))
-                        toRemove.Add(e);
-                }
-                result.RemoveAll(toRemove);
+                result.RetainAll(m_paramFields);
             }
             else
             {
diff --git a/src/Lucene.Net.Benchmark/ByTask/Tasks/SearchTravRetVectorHighlightTask.cs b/src/Lucene.Net.Benchmark/ByTask/Tasks/SearchTravRetVectorHighlightTask.cs
index b898bc0..52afa31 100644
--- a/src/Lucene.Net.Benchmark/ByTask/Tasks/SearchTravRetVectorHighlightTask.cs
+++ b/src/Lucene.Net.Benchmark/ByTask/Tasks/SearchTravRetVectorHighlightTask.cs
@@ -126,14 +126,7 @@ namespace Lucene.Net.Benchmarks.ByTask.Tasks
             //if stored is false, then result will be empty, in which case just get all the
param fields
             if (m_paramFields.Count > 0 && result.Count > 0)
             {
-                //result.RetainAll(paramFields);
-                var toRemove = new List<string>();
-                foreach (var e in result)
-                {
-                    if (!m_paramFields.Contains(e))
-                        toRemove.Add(e);
-                }
-                result.RemoveAll(toRemove);
+                result.RetainAll(m_paramFields);
             }
             else
             {

Mime
View raw message