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/02/12 17:14:30 UTC

[lucenenet] 04/05: Lucene.Net.Tests.Index (TestBagOfPositions + TestBagOfPostings): Fixed performance issue due to converting int to string and string to int in the current culture

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 03f3bb97169d9c9e5208f6f74040461b03c06050
Author: Shad Storhaug <sh...@shadstorhaug.com>
AuthorDate: Tue Feb 11 14:13:27 2020 +0700

    Lucene.Net.Tests.Index (TestBagOfPositions + TestBagOfPostings): Fixed performance issue due to converting int to string and string to int in the current culture
---
 src/Lucene.Net.Tests/Index/TestBagOfPositions.cs | 5 +++--
 src/Lucene.Net.Tests/Index/TestBagOfPostings.cs  | 5 +++--
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/Lucene.Net.Tests/Index/TestBagOfPositions.cs b/src/Lucene.Net.Tests/Index/TestBagOfPositions.cs
index 6a93bfb..f152c98 100644
--- a/src/Lucene.Net.Tests/Index/TestBagOfPositions.cs
+++ b/src/Lucene.Net.Tests/Index/TestBagOfPositions.cs
@@ -6,6 +6,7 @@ using NUnit.Framework;
 using System;
 using System.Collections.Concurrent;
 using System.Collections.Generic;
+using System.Globalization;
 using System.Text;
 using System.Threading;
 using Console = Lucene.Net.Util.SystemConsole;
@@ -72,7 +73,7 @@ namespace Lucene.Net.Index
             }
             for (int i = 0; i < numTerms; i++)
             {
-                string term = Convert.ToString(i);
+                string term = Convert.ToString(i, CultureInfo.InvariantCulture);
                 for (int j = 0; j < i; j++)
                 {
                     postingsList.Add(term);
@@ -141,7 +142,7 @@ namespace Lucene.Net.Index
             BytesRef termBR;
             while ((termBR = termsEnum.Next()) != null)
             {
-                int value = Convert.ToInt32(termBR.Utf8ToString());
+                int value = Convert.ToInt32(termBR.Utf8ToString(), CultureInfo.InvariantCulture);
                 Assert.AreEqual(value, termsEnum.TotalTermFreq);
                 // don't really need to check more than this, as CheckIndex
                 // will verify that totalTermFreq == total number of positions seen
diff --git a/src/Lucene.Net.Tests/Index/TestBagOfPostings.cs b/src/Lucene.Net.Tests/Index/TestBagOfPostings.cs
index 68806a3..c9d82cf 100644
--- a/src/Lucene.Net.Tests/Index/TestBagOfPostings.cs
+++ b/src/Lucene.Net.Tests/Index/TestBagOfPostings.cs
@@ -10,6 +10,7 @@ using System.Threading;
 using JCG = J2N.Collections.Generic;
 using Console = Lucene.Net.Util.SystemConsole;
 using J2N.Collections.Generic.Extensions;
+using System.Globalization;
 
 namespace Lucene.Net.Index
 {
@@ -73,7 +74,7 @@ namespace Lucene.Net.Index
 
             for (int i = 0; i < numTerms; i++)
             {
-                string term = Convert.ToString(i);
+                string term = Convert.ToString(i, CultureInfo.InvariantCulture);
                 for (int j = 0; j < i; j++)
                 {
                     postingsList.Add(term);
@@ -124,7 +125,7 @@ namespace Lucene.Net.Index
             BytesRef term_;
             while ((term_ = termsEnum.Next()) != null)
             {
-                int value = Convert.ToInt32(term_.Utf8ToString());
+                int value = Convert.ToInt32(term_.Utf8ToString(), CultureInfo.InvariantCulture);
                 Assert.AreEqual(value, termsEnum.DocFreq);
                 // don't really need to check more than this, as CheckIndex
                 // will verify that docFreq == actual number of documents seen