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 2020/06/30 21:50:49 UTC

[lucenenet] 13/27: Lucene.Net.Analsis.TokenAttributes.CharTermAttribute::ResizeBuffer(): Use Array.Resize() rather than copy (#261)

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 98c029553cb377d2c899b341f9c778f97d243ae2
Author: Shad Storhaug <sh...@shadstorhaug.com>
AuthorDate: Mon Jun 29 08:14:27 2020 +0700

    Lucene.Net.Analsis.TokenAttributes.CharTermAttribute::ResizeBuffer(): Use Array.Resize() rather than copy (#261)
---
 src/Lucene.Net/Analysis/TokenAttributes/CharTermAttribute.cs | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/Lucene.Net/Analysis/TokenAttributes/CharTermAttribute.cs b/src/Lucene.Net/Analysis/TokenAttributes/CharTermAttribute.cs
index 06911cd..af180d6 100644
--- a/src/Lucene.Net/Analysis/TokenAttributes/CharTermAttribute.cs
+++ b/src/Lucene.Net/Analysis/TokenAttributes/CharTermAttribute.cs
@@ -71,9 +71,9 @@ namespace Lucene.Net.Analysis.TokenAttributes
             {
                 // Not big enough; create a new array with slight
                 // over allocation and preserve content
-                char[] newCharBuffer = new char[ArrayUtil.Oversize(newSize, RamUsageEstimator.NUM_BYTES_CHAR)];
-                Array.Copy(termBuffer, 0, newCharBuffer, 0, termBuffer.Length);
-                termBuffer = newCharBuffer;
+                
+                // LUCENENET: Resize rather than copy
+                Array.Resize(ref termBuffer, ArrayUtil.Oversize(newSize, RamUsageEstimator.NUM_BYTES_CHAR));
             }
             return termBuffer;
         }