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 2019/09/06 09:01:21 UTC

[lucenenet] 11/21: SWEEP: Lucene.Net.Benchmark: Changed casing and number conversion to use invariant 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 2198258af707da32d3bc3d9b576c183ee16c5be9
Author: Shad Storhaug <sh...@shadstorhaug.com>
AuthorDate: Tue Sep 3 12:44:09 2019 +0700

    SWEEP: Lucene.Net.Benchmark: Changed casing and number conversion to use invariant culture
---
 src/Lucene.Net.Benchmark/ByTask/Feeds/DocMaker.cs            | 2 +-
 src/Lucene.Net.Benchmark/ByTask/Feeds/EnwikiContentSource.cs | 2 +-
 src/Lucene.Net.Benchmark/ByTask/Feeds/GeonamesLineParser.cs  | 3 ++-
 src/Lucene.Net.Benchmark/Support/TagSoup/HTMLScanner.cs      | 3 ++-
 src/Lucene.Net.Benchmark/Support/TagSoup/Parser.cs           | 2 +-
 src/Lucene.Net.Benchmark/Support/TagSoup/Schema.cs           | 4 ++--
 6 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/src/Lucene.Net.Benchmark/ByTask/Feeds/DocMaker.cs b/src/Lucene.Net.Benchmark/ByTask/Feeds/DocMaker.cs
index 8ff3e7b..7e50689 100644
--- a/src/Lucene.Net.Benchmark/ByTask/Feeds/DocMaker.cs
+++ b/src/Lucene.Net.Benchmark/ByTask/Feeds/DocMaker.cs
@@ -285,7 +285,7 @@ namespace Lucene.Net.Benchmarks.ByTask.Feeds
 
             //util.cal.setTime(date);
             //int sec = util.cal.get(Calendar.HOUR_OF_DAY) * 3600 + util.cal.get(Calendar.MINUTE) * 60 + util.cal.get(Calendar.SECOND);
-            int sec = Convert.ToInt32(date.Value.ToUniversalTime().TimeOfDay.TotalSeconds);
+            int sec = Convert.ToInt32(date.Value.ToUniversalTime().TimeOfDay.TotalSeconds, CultureInfo.InvariantCulture);
 
             Field timeSecField = ds.GetNumericField(TIME_SEC_FIELD, NumericType.INT32);
             timeSecField.SetInt32Value(sec);
diff --git a/src/Lucene.Net.Benchmark/ByTask/Feeds/EnwikiContentSource.cs b/src/Lucene.Net.Benchmark/ByTask/Feeds/EnwikiContentSource.cs
index bc72b18..8375e4c 100644
--- a/src/Lucene.Net.Benchmark/ByTask/Feeds/EnwikiContentSource.cs
+++ b/src/Lucene.Net.Benchmark/ByTask/Feeds/EnwikiContentSource.cs
@@ -164,7 +164,7 @@ namespace Lucene.Net.Benchmarks.ByTask.Feeds
                         break;
                     case BODY:
                         body = contents.ToString();
-                        //workaround that startswith doesn't have an ignore case option, get at least 20 chars.
+                        //workaround that startswith doesn't have an ignore case option, get at least 10 chars.
                         string startsWith = body.Substring(0, Math.Min(10, contents.Length) - 0).ToLowerInvariant();
                         if (startsWith.StartsWith("#redirect", StringComparison.Ordinal))
                         {
diff --git a/src/Lucene.Net.Benchmark/ByTask/Feeds/GeonamesLineParser.cs b/src/Lucene.Net.Benchmark/ByTask/Feeds/GeonamesLineParser.cs
index d786a91..3a60092 100644
--- a/src/Lucene.Net.Benchmark/ByTask/Feeds/GeonamesLineParser.cs
+++ b/src/Lucene.Net.Benchmark/ByTask/Feeds/GeonamesLineParser.cs
@@ -1,4 +1,5 @@
 using System;
+using System.Globalization;
 using System.Text.RegularExpressions;
 
 namespace Lucene.Net.Benchmarks.ByTask.Feeds
@@ -43,7 +44,7 @@ namespace Lucene.Net.Benchmarks.ByTask.Feeds
             // 3578267, Morne du Vitet, Morne du Vitet, 17.88333, -62.8, ...
             // ID, Name, Alternate name (unused), Lat, Lon, ...
 
-            docData.ID = Convert.ToInt32(parts[0]);//note: overwrites ID assigned by LineDocSource
+            docData.ID = Convert.ToInt32(parts[0], CultureInfo.InvariantCulture);//note: overwrites ID assigned by LineDocSource
             docData.Name = parts[1];
             string latitude = parts[4];
             string longitude = parts[5];
diff --git a/src/Lucene.Net.Benchmark/Support/TagSoup/HTMLScanner.cs b/src/Lucene.Net.Benchmark/Support/TagSoup/HTMLScanner.cs
index 731b2e9..480dfb9 100644
--- a/src/Lucene.Net.Benchmark/Support/TagSoup/HTMLScanner.cs
+++ b/src/Lucene.Net.Benchmark/Support/TagSoup/HTMLScanner.cs
@@ -15,6 +15,7 @@
 
 using Sax;
 using System;
+using System.Globalization;
 using System.IO;
 
 namespace TagSoup
@@ -740,7 +741,7 @@ namespace TagSoup
         private static string NiceChar(int value)
         {
             if (value == '\n') return "\\n";
-            if (value < 32) return "0x" + value.ToString("X");
+            if (value < 32) return "0x" + value.ToString("X", CultureInfo.InvariantCulture);
             return "'" + ((char)value) + "'";
         }
     }
diff --git a/src/Lucene.Net.Benchmark/Support/TagSoup/Parser.cs b/src/Lucene.Net.Benchmark/Support/TagSoup/Parser.cs
index 2f74cbd..b132904 100644
--- a/src/Lucene.Net.Benchmark/Support/TagSoup/Parser.cs
+++ b/src/Lucene.Net.Benchmark/Support/TagSoup/Parser.cs
@@ -749,7 +749,7 @@ namespace TagSoup
                 {
                     for (int i = 0; i < length; i++)
                     {
-                        if (char.ToLower(buff[offset + i]) != char.ToLower(currentName[i]))
+                        if (char.ToLowerInvariant(buff[offset + i]) != char.ToLowerInvariant(currentName[i]))
                         {
                             realTag = false;
                             break;
diff --git a/src/Lucene.Net.Benchmark/Support/TagSoup/Schema.cs b/src/Lucene.Net.Benchmark/Support/TagSoup/Schema.cs
index 76a86f9..64e6ef9 100644
--- a/src/Lucene.Net.Benchmark/Support/TagSoup/Schema.cs
+++ b/src/Lucene.Net.Benchmark/Support/TagSoup/Schema.cs
@@ -51,7 +51,7 @@ namespace TagSoup
         public virtual void ElementType(string name, int model, int memberOf, int flags)
         {
             var e = new ElementType(name, model, memberOf, flags, this);
-            theElementTypes[name.ToLower()] = e;
+            theElementTypes[name.ToLowerInvariant()] = e;
             if (memberOf == M_ROOT)
             {
                 theRoot = e;
@@ -120,7 +120,7 @@ namespace TagSoup
         /// <returns>The corresponding <see cref="TagSoup.ElementType"/></returns>
         public virtual ElementType GetElementType(string name)
         {
-            return (ElementType)(theElementTypes[name.ToLower()]);
+            return (ElementType)(theElementTypes[name.ToLowerInvariant()]);
         }
 
         /// <summary>