Skip to content

Commit 97a8880

Browse files
author
Tammo Freese
committed
Performance: Bail out early if nothing is to be done
1 parent 06d30d4 commit 97a8880

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

Core/Source/NSString+DTLocalizableStringScanner.m

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,11 @@ - (NSString *)stringByRemovingSlashEscapes
198198

199199
- (NSString *)stringByDecodingUnicodeSequences
200200
{
201+
202+
if ([self rangeOfString:@"\\"].location == NSNotFound) {
203+
return [self copy];
204+
}
205+
201206
NSUInteger length = [self length];
202207

203208
NSCharacterSet *hex = [NSCharacterSet characterSetWithCharactersInString:@"0123456789abcdefABCDEF"];
@@ -308,6 +313,10 @@ - (NSString *)stringByDecodingUnicodeSequences
308313

309314
- (NSString *)stringByReplacingSlashEscapes
310315
{
316+
if ([self rangeOfString:@"\\"].location == NSNotFound) {
317+
return [self copy];
318+
}
319+
311320
NSUInteger length = [self length];
312321

313322
unichar *characters = calloc(length, sizeof(unichar));

0 commit comments

Comments
 (0)