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
The following commit(s) were added to refs/heads/master by this push:
new 8367304fa PERFORMANCE: Lucene.Net.Util.MergedEnumerator: Changed from
using inline string conversions when the generic type is string to
J2N.Collections.Generic.Comparer<T>, which is statically initialized with the
optimal comparer that matches Java behaviors.
8367304fa is described below
commit 8367304fa46c14e92f7df0a4ee344dbf9953595f
Author: Shad Storhaug <[email protected]>
AuthorDate: Tue Oct 18 17:13:30 2022 +0700
PERFORMANCE: Lucene.Net.Util.MergedEnumerator: Changed from using inline
string conversions when the generic type is string to
J2N.Collections.Generic.Comparer<T>, which is statically initialized with the
optimal comparer that matches Java behaviors.
---
src/Lucene.Net/Util/MergedIterator.cs | 18 ++++++------------
1 file changed, 6 insertions(+), 12 deletions(-)
diff --git a/src/Lucene.Net/Util/MergedIterator.cs
b/src/Lucene.Net/Util/MergedIterator.cs
index 359093802..a7b7ab356 100644
--- a/src/Lucene.Net/Util/MergedIterator.cs
+++ b/src/Lucene.Net/Util/MergedIterator.cs
@@ -1,7 +1,9 @@
using J2N.Text;
using Lucene.Net.Diagnostics;
using System;
+using System.Collections;
using System.Collections.Generic;
+using JCG = J2N.Collections.Generic;
namespace Lucene.Net.Util
{
@@ -105,7 +107,7 @@ namespace Lucene.Net.Util
public T Current => current;
- object System.Collections.IEnumerator.Current => Current;
+ object IEnumerator.Current => Current;
public void Reset()
{
@@ -167,16 +169,8 @@ namespace Lucene.Net.Util
protected internal override bool LessThan(SubEnumerator<C> a,
SubEnumerator<C> b)
{
- int cmp;
- // LUCNENENET specific: For strings, we need to ensure we
compare them ordinal
- if (typeof(C).Equals(typeof(string)))
- {
- cmp = (a.Current as string).CompareToOrdinal(b.Current as
string);
- }
- else
- {
- cmp = a.Current.CompareTo(b.Current);
- }
+ // LUCNENENET specific: For strings, we need to ensure we
compare ordinal to match Lucene
+ int cmp = JCG.Comparer<C>.Default.Compare(a.Current,
b.Current);
if (cmp != 0)
{
return cmp < 0;
@@ -268,7 +262,7 @@ namespace Lucene.Net.Util
public T Current => current;
- object System.Collections.IEnumerator.Current => Current;
+ object IEnumerator.Current => Current;
public void Reset()
{