lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nightowl...@apache.org
Subject [32/39] lucenenet git commit: Lucene.Net.Analysis.Util.OpenStringBuilder refactor: added overload to Write() method for StringBuilder
Date Sat, 04 Feb 2017 20:32:51 GMT
Lucene.Net.Analysis.Util.OpenStringBuilder refactor: added overload to Write() method for StringBuilder


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

Branch: refs/heads/api-work
Commit: 230c9f90f111dfe4010255fb89c90b3c467a898c
Parents: 252e30c
Author: Shad Storhaug <shad@shadstorhaug.com>
Authored: Sun Feb 5 02:12:16 2017 +0700
Committer: Shad Storhaug <shad@shadstorhaug.com>
Committed: Sun Feb 5 03:29:07 2017 +0700

----------------------------------------------------------------------
 .../Analysis/Util/OpenStringBuilder.cs            | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/230c9f90/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 8987189..3dfec5c 100644
--- a/src/Lucene.Net.Analysis.Common/Analysis/Util/OpenStringBuilder.cs
+++ b/src/Lucene.Net.Analysis.Common/Analysis/Util/OpenStringBuilder.cs
@@ -177,6 +177,13 @@ namespace Lucene.Net.Analysis.Util
             this.m_len += len;
         }
 
+        // LUCENENET specific overload for StringBuilder
+        public virtual void UnsafeWrite(StringBuilder b, int off, int len)
+        {
+            b.CopyTo(off, m_buf, this.m_len, len);
+            this.m_len += len;
+        }
+
         protected virtual void Resize(int len)
         {
             char[] newbuf = new char[Math.Max(m_buf.Length << 1, len)];
@@ -217,9 +224,16 @@ namespace Lucene.Net.Analysis.Util
             UnsafeWrite(b, off, len);
         }
 
-        public void Write(OpenStringBuilder arr) // LUCENENET TODO: Add overload for StringBuilder
+        public void Write(OpenStringBuilder arr)
+        {
+            Write(arr.m_buf, 0, arr.Length); // LUCENENET specific - changed to arr.m_len
(original was just len - appears to be a bug)
+        }
+
+        // LUCENENET specific overload for StringBuilder
+        public void Write(StringBuilder arr)
         {
-            Write(arr.m_buf, 0, m_len);
+            Reserve(arr.Length);
+            UnsafeWrite(arr, 0, arr.Length);
         }
 
         public virtual void Write(string s)


Mime
View raw message