Commit 68d8b934 by Tom Tromey Committed by Tom Tromey

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
parent 75fe7b2f
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;
......
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