Skip to content

Commit

Permalink
String comparison is unnecessary if lengths don't match.
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeabdullah committed Aug 27, 2012
1 parent 70aadff commit 2ca7571
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions KSPathUtilities.m
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -183,9 +183,13 @@ - (NSString *)ks_pathRelativeToDirectory:(NSString *)dirPath
if (componentRange.length > 0) if (componentRange.length > 0)
{ {
// Ignore components which just specify current directory // Ignore components which just specify current directory
if ([dirPath compare:@"." options:NSLiteralSearch range:componentRange] != NSOrderedSame) if (componentRange.length > 1 || [dirPath compare:@"." options:NSLiteralSearch range:componentRange] != NSOrderedSame)
{ {
NSAssert([dirPath compare:@".." options:NSLiteralSearch range:componentRange] != NSOrderedSame, @".. unsupported"); if (componentRange.length == 2)
{
NSAssert([dirPath compare:@".." options:NSLiteralSearch range:componentRange] != NSOrderedSame, @".. unsupported");
}

if ([result length]) [result appendString:@"/"]; if ([result length]) [result appendString:@"/"];
[result appendString:@".."]; [result appendString:@".."];
} }
Expand Down

0 comments on commit 2ca7571

Please sign in to comment.