StringBuffer.java (substring): Don't set `shared' on small Strings, even if buffer is already shared.

* java/lang/StringBuffer.java (substring): Don't set `shared' on
	small Strings, even if buffer is already shared.

From-SVN: r71726
This commit is contained in:
Bryce McKinlay 2003-09-24 06:19:24 +00:00 committed by Bryce McKinlay
parent 4112c7bde0
commit afa1ee5e6f
2 changed files with 10 additions and 4 deletions

View file

@ -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.

View file

@ -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);
}
/**