+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
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;