This is the mail archive of the java@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: String.substring() question


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]