Commit afa1ee5e by Bryce McKinlay Committed by Bryce McKinlay

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

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
parent 4112c7bd
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.
......
......@@ -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);
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment