lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nightowl...@apache.org
Subject [33/39] lucenenet git commit: Lucene.Net.Analysis.Util.OpenStringBuilder refactor: Reserve() > EnsureCapacity (to match StringBuilder)
Date Sat, 04 Feb 2017 20:32:52 GMT
Lucene.Net.Analysis.Util.OpenStringBuilder refactor: Reserve() > EnsureCapacity (to match
StringBuilder)


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

Branch: refs/heads/api-work
Commit: b6c09987e3660ebb11f0c46fd7712693c5d6449c
Parents: 230c9f9
Author: Shad Storhaug <shad@shadstorhaug.com>
Authored: Sun Feb 5 02:40:10 2017 +0700
Committer: Shad Storhaug <shad@shadstorhaug.com>
Committed: Sun Feb 5 03:29:08 2017 +0700

----------------------------------------------------------------------
 .../Analysis/En/KStemmer.cs                       |  2 +-
 .../Analysis/Util/OpenStringBuilder.cs            | 18 +++++++++---------
 2 files changed, 10 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/b6c09987/src/Lucene.Net.Analysis.Common/Analysis/En/KStemmer.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Analysis.Common/Analysis/En/KStemmer.cs b/src/Lucene.Net.Analysis.Common/Analysis/En/KStemmer.cs
index b861ec3..c446532 100644
--- a/src/Lucene.Net.Analysis.Common/Analysis/En/KStemmer.cs
+++ b/src/Lucene.Net.Analysis.Common/Analysis/En/KStemmer.cs
@@ -1926,7 +1926,7 @@ namespace Lucene.Net.Analysis.En
 
             word.Reset();
             // allocate enough space so that an expansion is never needed
-            word.Reserve(len + 10);
+            word.EnsureCapacity(len + 10);
             for (int i = 0; i < len; i++)
             {
                 char ch = term[i];

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/b6c09987/src/Lucene.Net.Analysis.Common/Analysis/Util/OpenStringBuilder.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Analysis.Common/Analysis/Util/OpenStringBuilder.cs b/src/Lucene.Net.Analysis.Common/Analysis/Util/OpenStringBuilder.cs
index 3dfec5c..b72f116 100644
--- a/src/Lucene.Net.Analysis.Common/Analysis/Util/OpenStringBuilder.cs
+++ b/src/Lucene.Net.Analysis.Common/Analysis/Util/OpenStringBuilder.cs
@@ -89,7 +89,7 @@ namespace Lucene.Net.Analysis.Util
 
         public virtual OpenStringBuilder Append(ICharSequence csq, int start, int end)
         {
-            Reserve(end - start);
+            EnsureCapacity(end - start);
             for (int i = start; i < end; i++)
             {
                 UnsafeWrite(csq[i]);
@@ -106,7 +106,7 @@ namespace Lucene.Net.Analysis.Util
         // LUCENENET specific - overload for string (more common in .NET than ICharSequence)
         public virtual OpenStringBuilder Append(string csq, int start, int end)
         {
-            Reserve(end - start);
+            EnsureCapacity(end - start);
             for (int i = start; i < end; i++)
             {
                 UnsafeWrite(csq[i]);
@@ -123,7 +123,7 @@ namespace Lucene.Net.Analysis.Util
         // LUCENENET specific - overload for StringBuilder
         public virtual OpenStringBuilder Append(StringBuilder csq, int start, int end)
         {
-            Reserve(end - start);
+            EnsureCapacity(end - start);
             for (int i = start; i < end; i++)
             {
                 UnsafeWrite(csq[i]);
@@ -191,11 +191,11 @@ namespace Lucene.Net.Analysis.Util
             m_buf = newbuf;
         }
 
-        public virtual void Reserve(int num)
+        public virtual void EnsureCapacity(int capacity) // LUCENENET NOTE: renamed from
reserve() in Lucene to match .NET StringBuilder
         {
-            if (m_len + num > m_buf.Length)
+            if (m_len + capacity > m_buf.Length)
             {
-                Resize(m_len + num);
+                Resize(m_len + capacity);
             }
         }
 
@@ -220,7 +220,7 @@ namespace Lucene.Net.Analysis.Util
 
         public virtual void Write(char[] b, int off, int len)
         {
-            Reserve(len);
+            EnsureCapacity(len);
             UnsafeWrite(b, off, len);
         }
 
@@ -232,13 +232,13 @@ namespace Lucene.Net.Analysis.Util
         // LUCENENET specific overload for StringBuilder
         public void Write(StringBuilder arr)
         {
-            Reserve(arr.Length);
+            EnsureCapacity(arr.Length);
             UnsafeWrite(arr, 0, arr.Length);
         }
 
         public virtual void Write(string s)
         {
-            Reserve(s.Length);
+            EnsureCapacity(s.Length);
             s.CopyTo(0, m_buf, m_len, s.Length - 0);
             m_len += s.Length;
         }


Mime
View raw message