lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nightowl...@apache.org
Subject [32/50] [abbrv] lucenenet git commit: PERFORMANCE: Lucene.Net.Analysis.Common.Analysis.Util.CharacterUtils: ToLower and ToUpper .NET-ified enhancement provided by Vincent Van Den Berghe
Date Wed, 15 Mar 2017 23:50:14 GMT
PERFORMANCE: Lucene.Net.Analysis.Common.Analysis.Util.CharacterUtils: ToLower and ToUpper .NET-ified
enhancement provided by Vincent Van Den Berghe


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

Branch: refs/heads/api-work
Commit: 331fb470dcaf861dd0e52d923833e11c37c71b7d
Parents: e61076a
Author: Shad Storhaug <shad@shadstorhaug.com>
Authored: Wed Mar 15 15:59:19 2017 +0700
Committer: Shad Storhaug <shad@shadstorhaug.com>
Committed: Wed Mar 15 16:03:37 2017 +0700

----------------------------------------------------------------------
 .../Analysis/Util/CharacterUtils.cs             | 38 +++++++++++++-------
 1 file changed, 26 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/331fb470/src/Lucene.Net.Analysis.Common/Analysis/Util/CharacterUtils.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Analysis.Common/Analysis/Util/CharacterUtils.cs b/src/Lucene.Net.Analysis.Common/Analysis/Util/CharacterUtils.cs
index d1177ca..19097e0 100644
--- a/src/Lucene.Net.Analysis.Common/Analysis/Util/CharacterUtils.cs
+++ b/src/Lucene.Net.Analysis.Common/Analysis/Util/CharacterUtils.cs
@@ -137,12 +137,19 @@ namespace Lucene.Net.Analysis.Util
         {
             Debug.Assert(buffer.Length >= limit);
             Debug.Assert(offset <= 0 && offset <= buffer.Length);
-            for (int i = offset; i < limit; )
-            {
-                i += Character.ToChars(
-                    Character.ToLowerCase(
-                        CodePointAt(buffer, i, limit)), buffer, i);
-            }
+
+            // Optimization provided by Vincent Van Den Berghe: 
+            // http://search-lucene.com/m/Lucene.Net/j1zMf1uckOzOYqsi?subj=Proposal+to+speed+up+implementation+of+LowercaseFilter+charUtils+ToLower
+            new string(buffer, offset, limit)
+                .ToLowerInvariant()
+                .CopyTo(0, buffer, offset, limit);
+
+            //for (int i = offset; i < limit; )
+            //{
+            //    i += Character.ToChars(
+            //        Character.ToLowerCase(
+            //            CodePointAt(buffer, i, limit)), buffer, i);
+            //}
         }
 
         /// <summary>
@@ -155,12 +162,19 @@ namespace Lucene.Net.Analysis.Util
         {
             Debug.Assert(buffer.Length >= limit);
             Debug.Assert(offset <= 0 && offset <= buffer.Length);
-            for (int i = offset; i < limit; )
-            {
-                i += Character.ToChars(
-                    Character.ToUpperCase(
-                        CodePointAt(buffer, i, limit)), buffer, i);
-            }
+
+            // Optimization provided by Vincent Van Den Berghe: 
+            // http://search-lucene.com/m/Lucene.Net/j1zMf1uckOzOYqsi?subj=Proposal+to+speed+up+implementation+of+LowercaseFilter+charUtils+ToLower
+            new string(buffer, offset, limit)
+                .ToUpperInvariant()
+                .CopyTo(0, buffer, offset, limit);
+
+            //for (int i = offset; i < limit; )
+            //{
+            //    i += Character.ToChars(
+            //        Character.ToUpperCase(
+            //            CodePointAt(buffer, i, limit)), buffer, i);
+            //}
         }
 
         /// <summary>


Mime
View raw message