|
@@ -80,19 +80,18 @@ class String {
|
|
}
|
|
}
|
|
|
|
|
|
public function lastIndexOf( str : String, ?startIndex : Int ) : Int {
|
|
public function lastIndexOf( str : String, ?startIndex : Int ) : Int {
|
|
- var last = 0;
|
|
|
|
var max = this.length;
|
|
var max = this.length;
|
|
if( startIndex != null ) {
|
|
if( startIndex != null ) {
|
|
max = startIndex + str.length;
|
|
max = startIndex + str.length;
|
|
if( max < 0 ) max = 0;
|
|
if( max < 0 ) max = 0;
|
|
if( max > this.length ) max = this.length;
|
|
if( max > this.length ) max = this.length;
|
|
}
|
|
}
|
|
- max <<= 1;
|
|
|
|
- while( true ) {
|
|
|
|
- var p = findChar(last, max, str.bytes, str.length << 1);
|
|
|
|
- if( p < 0 )
|
|
|
|
- return (last >> 1) - 1;
|
|
|
|
- last = p + 2;
|
|
|
|
|
|
+ var pos = max - str.length;
|
|
|
|
+ var slen = str.length << 1;
|
|
|
|
+ while( pos >= 0 ) {
|
|
|
|
+ if( bytes.compare(pos << 1, str.bytes, 0, slen) == 0 )
|
|
|
|
+ return pos;
|
|
|
|
+ pos--;
|
|
}
|
|
}
|
|
return -1;
|
|
return -1;
|
|
}
|
|
}
|