natString.cc (substring): optimize where substring is entire String.
1999-07-22 Bryce McKinlay <bryce@albatross.co.nz> * java/lang/natString.cc (substring): optimize where substring is entire String. * java/io/File.java (getName): don't return separator with file name. * java/io/natFile.cc (attr): fix overflow. From-SVN: r28246
This commit is contained in:
parent
648d2ffce8
commit
41296e2a23
4 changed files with 11 additions and 4 deletions
|
@ -687,6 +687,8 @@ java::lang::String::substring (jint beginIndex, jint endIndex)
|
|||
{
|
||||
if (beginIndex < 0 || endIndex > count || beginIndex > endIndex)
|
||||
JvThrow (new StringIndexOutOfBoundsException());
|
||||
if (beginIndex == 0 && endIndex == count)
|
||||
return this;
|
||||
jint newCount = endIndex - beginIndex;
|
||||
if (newCount <= 8) // Optimization, mainly for GC.
|
||||
return JvNewString(JvGetStringChars(this) + beginIndex, newCount);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue