This is the mail archive of the
java@gcc.gnu.org
mailing list for the Java project.
Re: String.substring() question
- To: Per Bothner <per at bothner dot com>
- Subject: Re: String.substring() question
- From: Tom Tromey <tromey at redhat dot com>
- Date: 17 May 2001 12:12:14 -0600
- Cc: Java Discuss List <java at gcc dot gnu dot org>
- References: <87heykbztx.fsf@creche.redhat.com> <m28zjwx1c3.fsf@kelso.bothner.com>
- Reply-To: tromey at redhat dot com
Per> if (newCount <= 8) // Optimization, mainly for GC.
Per> return JvNewString(JvGetStringChars(this) + beginIndex, newCount);
Thanks, I missed that.
This isn't really what I was getting at though. If we are making a
substring of a String which is already small, then copying it seems
less efficient than referring to it. But if we make a small substring
of a very large String then copying it might often be better -- if if
the "small" is only relative. For instance a 1K substring of a 1M
String "should" (if we had perfect knowledge) be copied if it is the
only thing keeping the String alive.
Tom