lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nightowl...@apache.org
Subject [08/47] lucenenet git commit: Fixed Regex bug in Core.Index.TestDuelingCodecs
Date Tue, 11 Oct 2016 18:34:53 GMT
Fixed Regex bug in Core.Index.TestDuelingCodecs


Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/2fa691b9
Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/2fa691b9
Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/2fa691b9

Branch: refs/heads/master
Commit: 2fa691b9e3ba1c0b7db3baf1dd82f13060a5e1c7
Parents: 12a8118
Author: Shad Storhaug <shad@shadstorhaug.com>
Authored: Sat Oct 8 12:55:37 2016 +0700
Committer: Shad Storhaug <shad@shadstorhaug.com>
Committed: Sat Oct 8 17:15:41 2016 +0700

----------------------------------------------------------------------
 src/Lucene.Net.Tests/core/Index/TestDuelingCodecs.cs | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/2fa691b9/src/Lucene.Net.Tests/core/Index/TestDuelingCodecs.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/core/Index/TestDuelingCodecs.cs b/src/Lucene.Net.Tests/core/Index/TestDuelingCodecs.cs
index 624708a..06c3dbb 100644
--- a/src/Lucene.Net.Tests/core/Index/TestDuelingCodecs.cs
+++ b/src/Lucene.Net.Tests/core/Index/TestDuelingCodecs.cs
@@ -4,6 +4,7 @@ using System;
 
 namespace Lucene.Net.Index
 {
+    using System.Text.RegularExpressions;
     using BytesRef = Lucene.Net.Util.BytesRef;
     using Codec = Lucene.Net.Codecs.Codec;
     using Directory = Lucene.Net.Store.Directory;
@@ -138,6 +139,9 @@ namespace Lucene.Net.Index
             // primary source for our data is from linefiledocs, its realistic.
             LineFileDocs lineFileDocs = new LineFileDocs(random);
 
+            // LUCENENET: compile a regex so we don't have to do it in each loop (for regex.split())
+            Regex whiteSpace = new Regex("\\s+", RegexOptions.Compiled);
+
             // TODO: we should add other fields that use things like docs&freqs but omit
positions,
             // because linefiledocs doesn't cover all the possibilities.
             for (int i = 0; i < numdocs; i++)
@@ -145,7 +149,7 @@ namespace Lucene.Net.Index
                 Document document = lineFileDocs.NextDoc();
                 // grab the title and add some SortedSet instances for fun
                 string title = document.Get("titleTokenized");
-                string[] split = title.Split("\\s+".ToCharArray());
+                string[] split = whiteSpace.Split(title);
                 foreach (string trash in split)
                 {
                     document.Add(new SortedSetDocValuesField("sortedset", new BytesRef(trash)));


Mime
View raw message