@@ -311,9 +311,10 @@ - (id) deserialize:(id) data class:(NSString *) class {
311
311
range: NSMakeRange (0 , [class length ])];
312
312
313
313
if (match) {
314
+ NSArray *dataArray = data;
314
315
innerType = [class substringWithRange: [match rangeAtIndex: 1 ]];
315
316
316
- resultArray = [NSMutableArray arrayWithCapacity: [data count ]];
317
+ resultArray = [NSMutableArray arrayWithCapacity: [dataArray count ]];
317
318
[data enumerateObjectsUsingBlock: ^(id obj, NSUInteger idx, BOOL *stop) {
318
319
[resultArray addObject: [self deserialize: obj class: innerType]];
319
320
}
@@ -332,9 +333,10 @@ - (id) deserialize:(id) data class:(NSString *) class {
332
333
range: NSMakeRange (0 , [class length ])];
333
334
334
335
if (match) {
336
+ NSArray *dataArray = data;
335
337
innerType = [class substringWithRange: [match rangeAtIndex: 1 ]];
336
338
337
- resultArray = [NSMutableArray arrayWithCapacity: [data count ]];
339
+ resultArray = [NSMutableArray arrayWithCapacity: [dataArray count ]];
338
340
[data enumerateObjectsUsingBlock: ^(id obj, NSUInteger idx, BOOL *stop) {
339
341
[resultArray addObject: [self deserialize: obj class: innerType]];
340
342
}];
@@ -352,9 +354,10 @@ - (id) deserialize:(id) data class:(NSString *) class {
352
354
range: NSMakeRange (0 , [class length ])];
353
355
354
356
if (match) {
357
+ NSDictionary *dataDict = data;
355
358
NSString *valueType = [class substringWithRange: [match rangeAtIndex: 2 ]];
356
359
357
- resultDict = [NSMutableDictionary dictionaryWithCapacity: [data count ]];
360
+ resultDict = [NSMutableDictionary dictionaryWithCapacity: [dataDict count ]];
358
361
[data enumerateKeysAndObjectsUsingBlock: ^(id key, id obj, BOOL *stop) {
359
362
[resultDict setValue: [self deserialize: obj class: valueType] forKey: key];
360
363
}];
@@ -728,7 +731,8 @@ - (id) sanitizeForSerialization:(id) object {
728
731
return [object ISO8601String ];
729
732
}
730
733
else if ([object isKindOfClass: [NSArray class ]]) {
731
- NSMutableArray *sanitizedObjs = [NSMutableArray arrayWithCapacity: [object count ]];
734
+ NSArray *objectArray = object;
735
+ NSMutableArray *sanitizedObjs = [NSMutableArray arrayWithCapacity: [objectArray count ]];
732
736
[object enumerateObjectsUsingBlock: ^(id obj, NSUInteger idx, BOOL *stop) {
733
737
if (obj) {
734
738
[sanitizedObjs addObject: [self sanitizeForSerialization: obj]];
@@ -737,7 +741,8 @@ - (id) sanitizeForSerialization:(id) object {
737
741
return sanitizedObjs;
738
742
}
739
743
else if ([object isKindOfClass: [NSDictionary class ]]) {
740
- NSMutableDictionary *sanitizedObjs = [NSMutableDictionary dictionaryWithCapacity: [object count ]];
744
+ NSDictionary *objectDict = object;
745
+ NSMutableDictionary *sanitizedObjs = [NSMutableDictionary dictionaryWithCapacity: [objectDict count ]];
741
746
[object enumerateKeysAndObjectsUsingBlock: ^(id key, id obj, BOOL *stop) {
742
747
if (obj) {
743
748
[sanitizedObjs setValue: [self sanitizeForSerialization: obj] forKey: key];
0 commit comments