mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-10-27 02:25:36 +00:00
Fixed CPString's commonPrefixWithString to be faster.
This commit is contained in:
1 parent
0575e96b60
commit
4fdddfb585
1 file changed
+10
-10
+10
-10
@@ -557,19 +557,19 @@ var CPStringRegexSpecialCharacters = [
|
||||
{
|
||||
var len = 0, // length of common prefix
|
||||
min = MIN([aString length], [self length]);
|
||||
|
||||
var lhs = self,
|
||||
rhs = aString;
|
||||
|
||||
if (aMask & CPCaseInsensitiveSearch)
|
||||
{
|
||||
lhs = [lhs lowercaseString];
|
||||
rhs = [rhs lowercaseString];
|
||||
}
|
||||
|
||||
for ( len = 0; len < min; len++ )
|
||||
{
|
||||
var lhs = [self characterAtIndex: len],
|
||||
rhs = [aString characterAtIndex: len];
|
||||
|
||||
if (aMask & CPCaseInsensitiveSearch)
|
||||
{
|
||||
lhs = [lhs lowercaseString];
|
||||
rhs = [rhs lowercaseString];
|
||||
}
|
||||
|
||||
if ( lhs != rhs )
|
||||
if ( [lhs characterAtIndex: len] != [rhs characterAtIndex: len] )
|
||||
break;
|
||||
}
|
||||
return [self substringToIndex: len];
|
||||
|
||||
Reference in new issue
Block a user