summaryrefslogtreecommitdiffstats
path: root/libjava/java
diff options
context:
space:
mode:
authortromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4>2005-06-01 15:52:45 +0000
committertromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4>2005-06-01 15:52:45 +0000
commit61ef64167ce0275c52cd71312c85692fdc3702da (patch)
treed45776264c7ddfe40e12a61a6bd2555f42877538 /libjava/java
parentc0e1af525097b01a93fa2186146366336f9b7f05 (diff)
downloadppe42-gcc-61ef64167ce0275c52cd71312c85692fdc3702da.tar.gz
ppe42-gcc-61ef64167ce0275c52cd71312c85692fdc3702da.zip
PR libgcj/21753:
* java/lang/natString.cc (substring): Changed sharing heuristic. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@100454 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava/java')
-rw-r--r--libjava/java/lang/natString.cc5
1 files changed, 4 insertions, 1 deletions
diff --git a/libjava/java/lang/natString.cc b/libjava/java/lang/natString.cc
index a14f5de9d6e..c8f3129a212 100644
--- a/libjava/java/lang/natString.cc
+++ b/libjava/java/lang/natString.cc
@@ -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;
OpenPOWER on IntegriCloud