diff options
Diffstat (limited to 'libjava')
-rw-r--r-- | libjava/ChangeLog | 5 | ||||
-rw-r--r-- | libjava/java/lang/StringBuffer.java | 9 |
2 files changed, 10 insertions, 4 deletions
diff --git a/libjava/ChangeLog b/libjava/ChangeLog index cadf1aa..3100d2f 100644 --- a/libjava/ChangeLog +++ b/libjava/ChangeLog @@ -1,3 +1,8 @@ +2003-09-24 Bryce McKinlay <bryce@mckinlay.net.nz> + + * java/lang/StringBuffer.java (substring): Don't set `shared' on small + Strings, even if buffer is already shared. + 2003-09-24 Michael Koch <konqueror@gmx.de> * acinclude.m4 (AM_LC_LOCALES): Added check for locale.h. diff --git a/libjava/java/lang/StringBuffer.java b/libjava/java/lang/StringBuffer.java index a7c2590..0903b40 100644 --- a/libjava/java/lang/StringBuffer.java +++ b/libjava/java/lang/StringBuffer.java @@ -564,11 +564,12 @@ public final class StringBuffer implements Serializable, CharSequence throw new StringIndexOutOfBoundsException(); if (len == 0) return ""; - // Share unless substring is smaller than 1/4 of the buffer. - if ((len << 2) >= value.length) - shared = true; + // Don't copy unless substring is smaller than 1/4 of the buffer. + boolean share_buffer = ((len << 2) >= value.length); + if (share_buffer) + this.shared = true; // Package constructor avoids an array copy. - return new String(value, beginIndex, len, shared); + return new String(value, beginIndex, len, share_buffer); } /** |