mirror of
https://github.com/gcc-mirror/gcc.git
synced 2026-05-06 23:25:24 +02:00
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:
committed by
Bryce McKinlay
parent
4112c7bde0
commit
afa1ee5e6f
@@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user