< prev index next >

src/java.base/share/classes/java/lang/AbstractStringBuilder.java

Print this page

        

*** 24,34 **** */ package java.lang; import jdk.internal.math.FloatingDecimal; - import java.util.Arrays; import java.util.Spliterator; import java.util.stream.IntStream; import java.util.stream.StreamSupport; --- 24,33 ----
*** 684,702 **** s = "null"; } checkRange(start, end, s.length()); int len = end - start; ensureCapacityInternal(count + len); ! if (s instanceof String) { ! appendChars((String)s, start, end); ! } else { ! appendChars(s, start, end); ! } return this; } - /** * Appends the string representation of the {@code char} array * argument to this sequence. * <p> * The characters of the array argument are appended, in order, to --- 683,696 ---- s = "null"; } checkRange(start, end, s.length()); int len = end - start; ensureCapacityInternal(count + len); ! appendChars(s, start, end); return this; } /** * Appends the string representation of the {@code char} array * argument to this sequence. * <p> * The characters of the array argument are appended, in order, to
*** 1747,1785 **** StringUTF16.putCharsSB(this.value, count, s, off, end); } this.count = count + end - off; } - private final void appendChars(String s, int off, int end) { - if (isLatin1()) { - if (s.isLatin1()) { - System.arraycopy(s.value(), off, this.value, this.count, end - off); - } else { - // We might need to inflate, but do it as late as possible since - // the range of characters we're copying might all be latin1 - byte[] val = this.value; - for (int i = off, j = count; i < end; i++) { - char c = s.charAt(i); - if (StringLatin1.canEncode(c)) { - val[j++] = (byte) c; - } else { - count = j; - inflate(); - System.arraycopy(s.value(), i << UTF16, this.value, j << UTF16, (end - i) << UTF16); - count += end - i; - return; - } - } - } - } else if (s.isLatin1()) { - StringUTF16.putCharsSB(this.value, this.count, s, off, end); - } else { // both UTF16 - System.arraycopy(s.value(), off << UTF16, this.value, this.count << UTF16, (end - off) << UTF16); - } - count += end - off; - } - private final void appendChars(CharSequence s, int off, int end) { if (isLatin1()) { byte[] val = this.value; for (int i = off, j = count; i < end; i++) { char c = s.charAt(i); --- 1741,1750 ----
< prev index next >