You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucenenet.apache.org by ni...@apache.org on 2020/07/21 09:48:50 UTC
[lucenenet] 16/24: PERFORMANCE:
Lucene.Net.Search.NumericRangeQuery: Changed rangeBounds from LinkedList to
Queue
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 4eb22840add28d0265b9274d785ee588a3c4f6d7
Author: Shad Storhaug <sh...@shadstorhaug.com>
AuthorDate: Sat Jul 18 02:29:48 2020 +0700
PERFORMANCE: Lucene.Net.Search.NumericRangeQuery: Changed rangeBounds from LinkedList to Queue
---
src/Lucene.Net/Search/NumericRangeQuery.cs | 18 ++++++++----------
1 file changed, 8 insertions(+), 10 deletions(-)
diff --git a/src/Lucene.Net/Search/NumericRangeQuery.cs b/src/Lucene.Net/Search/NumericRangeQuery.cs
index a91cab6..aeef50b 100644
--- a/src/Lucene.Net/Search/NumericRangeQuery.cs
+++ b/src/Lucene.Net/Search/NumericRangeQuery.cs
@@ -300,7 +300,7 @@ namespace Lucene.Net.Search
internal BytesRef currentLowerBound, currentUpperBound;
- internal readonly LinkedList<BytesRef> rangeBounds = new LinkedList<BytesRef>();
+ internal readonly Queue<BytesRef> rangeBounds = new Queue<BytesRef>();
internal readonly IComparer<BytesRef> termComp;
internal NumericRangeTermsEnum(NumericRangeQuery<T> outerInstance, TermsEnum tenum)
@@ -422,8 +422,8 @@ namespace Lucene.Net.Search
public override sealed void AddRange(BytesRef minPrefixCoded, BytesRef maxPrefixCoded)
{
- outerInstance.rangeBounds.AddLast(minPrefixCoded);
- outerInstance.rangeBounds.AddLast(maxPrefixCoded);
+ outerInstance.rangeBounds.Enqueue(minPrefixCoded);
+ outerInstance.rangeBounds.Enqueue(maxPrefixCoded);
}
}
@@ -438,8 +438,8 @@ namespace Lucene.Net.Search
public override sealed void AddRange(BytesRef minPrefixCoded, BytesRef maxPrefixCoded)
{
- outerInstance.rangeBounds.AddLast(minPrefixCoded);
- outerInstance.rangeBounds.AddLast(maxPrefixCoded);
+ outerInstance.rangeBounds.Enqueue(minPrefixCoded);
+ outerInstance.rangeBounds.Enqueue(maxPrefixCoded);
}
}
@@ -447,12 +447,10 @@ namespace Lucene.Net.Search
{
Debug.Assert(rangeBounds.Count % 2 == 0);
- currentLowerBound = rangeBounds.First.Value;
- rangeBounds.Remove(currentLowerBound);
+ currentLowerBound = rangeBounds.Dequeue();
Debug.Assert(currentUpperBound == null || termComp.Compare(currentUpperBound, currentLowerBound) <= 0, "The current upper bound must be <= the new lower bound");
- currentUpperBound = rangeBounds.First.Value;
- rangeBounds.Remove(currentUpperBound);
+ currentUpperBound = rangeBounds.Dequeue();
}
protected override sealed BytesRef NextSeekTerm(BytesRef term)
@@ -485,7 +483,7 @@ namespace Lucene.Net.Search
return AcceptStatus.END;
}
// peek next sub-range, only seek if the current term is smaller than next lower bound
- if (termComp.Compare(term, rangeBounds.First.Value) < 0)
+ if (termComp.Compare(term, rangeBounds.Peek()) < 0)
{
return AcceptStatus.NO_AND_SEEK;
}