re PR libgcj/21753 (String.substring sharing heuristic should be improved)
PR libgcj/21753: * java/lang/natString.cc (substring): Changed sharing heuristic. From-SVN: r100454
This commit is contained in:
parent
75fe7b2f40
commit
68d8b93454
2 changed files with 9 additions and 1 deletions
|
@ -833,7 +833,10 @@ java::lang::String::substring (jint beginIndex, jint endIndex)
|
|||
if (beginIndex == 0 && endIndex == count)
|
||||
return this;
|
||||
jint newCount = endIndex - beginIndex;
|
||||
if (newCount <= 8) // Optimization, mainly for GC.
|
||||
// For very small strings, just allocate a new one. For other
|
||||
// substrings, allocate a new one unless the substring is over half
|
||||
// of the original string.
|
||||
if (newCount <= 8 || newCount < (count >> 1))
|
||||
return JvNewString(JvGetStringChars(this) + beginIndex, newCount);
|
||||
jstring s = new String();
|
||||
s->data = data;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue