diff options
author | Tom Tromey <tromey@redhat.com> | 2005-06-01 15:52:45 +0000 |
---|---|---|
committer | Tom Tromey <tromey@gcc.gnu.org> | 2005-06-01 15:52:45 +0000 |
commit | 68d8b93454c20a663d4b259919d487fe16519837 (patch) | |
tree | d45776264c7ddfe40e12a61a6bd2555f42877538 /libjava | |
parent | 75fe7b2f406d638fa6de89c44e0a862ab04a0b5e (diff) | |
download | gcc-68d8b93454c20a663d4b259919d487fe16519837.zip gcc-68d8b93454c20a663d4b259919d487fe16519837.tar.gz gcc-68d8b93454c20a663d4b259919d487fe16519837.tar.bz2 |
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
Diffstat (limited to 'libjava')
-rw-r--r-- | libjava/ChangeLog | 5 | ||||
-rw-r--r-- | libjava/java/lang/natString.cc | 5 |
2 files changed, 9 insertions, 1 deletions
diff --git a/libjava/ChangeLog b/libjava/ChangeLog index ca9f2f4..cddaecb 100644 --- a/libjava/ChangeLog +++ b/libjava/ChangeLog @@ -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 diff --git a/libjava/java/lang/natString.cc b/libjava/java/lang/natString.cc index a14f5de..c8f3129 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; |