changeset 49296:fc16b5f193c7

8198955: String#repeat loop optimization Reviewed-by: rriggs, redestad, igerasim
author jlaskey
date Fri, 02 Mar 2018 18:10:57 -0400
parents 10f447530d32
children d8057fc6fffc
files src/java.base/share/classes/java/lang/String.java
diffstat 1 files changed, 1 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/java.base/share/classes/java/lang/String.java	Fri Mar 02 14:17:04 2018 -0500
+++ b/src/java.base/share/classes/java/lang/String.java	Fri Mar 02 18:10:57 2018 -0400
@@ -3005,9 +3005,8 @@
         final byte[] multiple = new byte[limit];
         System.arraycopy(value, 0, multiple, 0, len);
         int copied = len;
-        for (int next = copied << 1; next < limit && 0 < next; next = next << 1) {
+        for (; copied < limit - copied; copied <<= 1) {
             System.arraycopy(multiple, 0, multiple, copied, copied);
-            copied = next;
         }
         System.arraycopy(multiple, 0, multiple, copied, limit - copied);
         return new String(multiple, coder);