re PR libgcj/12350 (StringBuffer.substring handles shared flag incorrected.)
2003-09-21 Ralph Loader <suckfish@ihug.co.nz> PR java/12350: * java/lang/StringBuffer.java (substring): Fix handling of shared flag. 2003-09-21 Ralph Loader <suckfish@ihug.co.nz> PR java/12350 * libjava.lang/PR12350.java: New file. * libjava.lang/PR12350.out: New file. From-SVN: r71651
This commit is contained in:
parent
b5bb72ec41
commit
88962108fc
5 changed files with 35 additions and 2 deletions
|
@ -564,8 +564,9 @@ public final class StringBuffer implements Serializable, CharSequence
|
|||
throw new StringIndexOutOfBoundsException();
|
||||
if (len == 0)
|
||||
return "";
|
||||
// Share the char[] unless 3/4 empty.
|
||||
shared = (len << 2) >= value.length;
|
||||
// Share unless substring is smaller than 1/4 of the buffer.
|
||||
if ((len << 2) >= value.length)
|
||||
shared = true;
|
||||
// Package constructor avoids an array copy.
|
||||
return new String(value, beginIndex, len, shared);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue