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
@ -1,3 +1,8 @@
|
||||
2005-06-01 Tom Tromey <tromey@redhat.com>
|
||||
|
||||
PR libgcj/21753:
|
||||
* java/lang/natString.cc (substring): Changed sharing heuristic.
|
||||
|
||||
2005-05-30 Bryce McKinlay <mckinlay@redhat.com>
|
||||
|
||||
PR libgcj/21821
|
||||
|
@ -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…
Reference in New Issue
Block a user