Skip to content

Commit

Permalink
fixing performance bug (see #64) in Objective-C implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
getify committed Dec 15, 2021
1 parent 9404f0f commit 150f0a2
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion NSString+minifyJSONString.m
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
// Created by Bödecs Tibor on 7/19/13.
// Copyright (c) 2013 Bödecs Tibor. All rights reserved.
//
// Patched by Kyle Simpson, 2021
//

#import "NSString+minifyJSONString.h"

Expand All @@ -20,6 +22,7 @@ - (NSString *)minifyJSONString
NSString *tmp2;
NSMutableArray *new_str = [@[] mutableCopy];
int from = 0;
int prevFrom = 0;
NSString *lc;
NSString *rc;
int lastIndex = 0;
Expand Down Expand Up @@ -53,12 +56,13 @@ - (NSString *)minifyJSONString
}
[new_str addObject:tmp2];
}
prevFrom = from;
from = lastIndex;

if ( [tmp hasPrefix:@"\""] && !in_multiline_comment && !in_singleline_comment) {
NSArray *_matches = [magic matchesInString:lc
options:0
range:NSMakeRange(0, lc.length)];
range:NSMakeRange(prevFrom, lc.length)];

if (_matches.count > 0 ) {
NSTextCheckingResult *_match = _matches[0];
Expand Down

0 comments on commit 150f0a2

Please sign in to comment.