You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2020/06/28 16:13:56 UTC

[commons-text] branch master updated (f50889a -> d9e675e)

This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/commons-text.git.


    from f50889a  Encapsulate but keep package private.
     new 719a0ef  Reuse JRE.
     new c2b4503  Reuse JRE.
     new 4258c75  Reuse JRE.
     new da668c8  Reuse JRE.
     new d9e675e  Reuse JRE.

The 5 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../org/apache/commons/text/TextStringBuilder.java | 29 ++++++----------------
 1 file changed, 7 insertions(+), 22 deletions(-)


[commons-text] 02/05: Reuse JRE.

Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-text.git

commit c2b45033853c69e4f3c9cc5114c41d8bfb7f21ed
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sun Jun 28 12:04:16 2020 -0400

    Reuse JRE.
---
 src/main/java/org/apache/commons/text/TextStringBuilder.java | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/src/main/java/org/apache/commons/text/TextStringBuilder.java b/src/main/java/org/apache/commons/text/TextStringBuilder.java
index db9110b..1914312 100644
--- a/src/main/java/org/apache/commons/text/TextStringBuilder.java
+++ b/src/main/java/org/apache/commons/text/TextStringBuilder.java
@@ -3140,12 +3140,7 @@ public class TextStringBuilder implements CharSequence, Appendable, Serializable
      * @return a new array that represents the contents of the builder
      */
     public char[] toCharArray() {
-        if (size == 0) {
-            return ArrayUtils.EMPTY_CHAR_ARRAY;
-        }
-        final char[] chars = new char[size];
-        System.arraycopy(buffer, 0, chars, 0, size);
-        return chars;
+        return size == 0 ? ArrayUtils.EMPTY_CHAR_ARRAY : Arrays.copyOf(buffer, size);
     }
 
     /**


[commons-text] 03/05: Reuse JRE.

Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-text.git

commit 4258c75cfa16b6762c22f0f5f5973c01172d2f55
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sun Jun 28 12:08:25 2020 -0400

    Reuse JRE.
---
 src/main/java/org/apache/commons/text/TextStringBuilder.java | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/src/main/java/org/apache/commons/text/TextStringBuilder.java b/src/main/java/org/apache/commons/text/TextStringBuilder.java
index 1914312..f69b118 100644
--- a/src/main/java/org/apache/commons/text/TextStringBuilder.java
+++ b/src/main/java/org/apache/commons/text/TextStringBuilder.java
@@ -3157,12 +3157,7 @@ public class TextStringBuilder implements CharSequence, Appendable, Serializable
     public char[] toCharArray(final int startIndex, int endIndex) {
         endIndex = validateRange(startIndex, endIndex);
         final int len = endIndex - startIndex;
-        if (len == 0) {
-            return ArrayUtils.EMPTY_CHAR_ARRAY;
-        }
-        final char[] chars = new char[len];
-        System.arraycopy(buffer, startIndex, chars, 0, len);
-        return chars;
+        return len == 0 ? ArrayUtils.EMPTY_CHAR_ARRAY : Arrays.copyOfRange(buffer, startIndex, endIndex);
     }
 
     /**


[commons-text] 05/05: Reuse JRE.

Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-text.git

commit d9e675e06070f578941dddda08593914804e6294
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sun Jun 28 12:13:49 2020 -0400

    Reuse JRE.
---
 src/main/java/org/apache/commons/text/TextStringBuilder.java | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/src/main/java/org/apache/commons/text/TextStringBuilder.java b/src/main/java/org/apache/commons/text/TextStringBuilder.java
index 43aa378..7936b94 100644
--- a/src/main/java/org/apache/commons/text/TextStringBuilder.java
+++ b/src/main/java/org/apache/commons/text/TextStringBuilder.java
@@ -2609,10 +2609,8 @@ public class TextStringBuilder implements CharSequence, Appendable, Serializable
      * @return this, to enable chaining
      */
     public TextStringBuilder minimizeCapacity() {
-        if (buffer.length > length()) {
-            final char[] old = buffer;
-            buffer = new char[length()];
-            System.arraycopy(old, 0, buffer, 0, size);
+        if (buffer.length > size) {
+            buffer = Arrays.copyOf(buffer, size);
         }
         return this;
     }


[commons-text] 04/05: Reuse JRE.

Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-text.git

commit da668c8a5918f7df42b514e6a8b70c5ecd7f6685
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sun Jun 28 12:11:07 2020 -0400

    Reuse JRE.
---
 src/main/java/org/apache/commons/text/TextStringBuilder.java | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/src/main/java/org/apache/commons/text/TextStringBuilder.java b/src/main/java/org/apache/commons/text/TextStringBuilder.java
index f69b118..43aa378 100644
--- a/src/main/java/org/apache/commons/text/TextStringBuilder.java
+++ b/src/main/java/org/apache/commons/text/TextStringBuilder.java
@@ -1895,9 +1895,7 @@ public class TextStringBuilder implements CharSequence, Appendable, Serializable
      */
     public TextStringBuilder ensureCapacity(final int capacity) {
         if (capacity > buffer.length) {
-            final char[] old = buffer;
-            buffer = new char[capacity * 2];
-            System.arraycopy(old, 0, buffer, 0, size);
+            buffer = Arrays.copyOf(buffer, capacity * 2);
         }
         return this;
     }


[commons-text] 01/05: Reuse JRE.

Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-text.git

commit 719a0efe03a332e834e2a2a2d7a7c2d80f607363
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sun Jun 28 12:02:03 2020 -0400

    Reuse JRE.
---
 src/main/java/org/apache/commons/text/TextStringBuilder.java | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/src/main/java/org/apache/commons/text/TextStringBuilder.java b/src/main/java/org/apache/commons/text/TextStringBuilder.java
index 565cff8..db9110b 100644
--- a/src/main/java/org/apache/commons/text/TextStringBuilder.java
+++ b/src/main/java/org/apache/commons/text/TextStringBuilder.java
@@ -21,6 +21,7 @@ import java.io.Reader;
 import java.io.Serializable;
 import java.io.Writer;
 import java.nio.CharBuffer;
+import java.util.Arrays;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Objects;
@@ -3010,9 +3011,7 @@ public class TextStringBuilder implements CharSequence, Appendable, Serializable
             final int oldEnd = size;
             final int newEnd = length;
             size = length;
-            for (int i = oldEnd; i < newEnd; i++) {
-                buffer[i] = '\0';
-            }
+            Arrays.fill(buffer, oldEnd, newEnd, '\0');
         }
         return this;
     }