mirror of
https://github.com/zhigang1992/RestKit.git
synced 2026-04-23 12:27:52 +08:00
fix performance of MappingOperation (#902)
This commit replaces the special handling of unix-timestamps into the existing dateformatter architecture. By adding it to the end of the list, it's still present, but doesn't 'cost' anything for all other users.
This commit is contained in:
@@ -105,15 +105,7 @@ BOOL RKObjectIsValueEqualToValue(id sourceValue, id destinationValue) {
|
||||
|
||||
NSDate *date = nil;
|
||||
|
||||
NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init];
|
||||
numberFormatter.numberStyle = NSNumberFormatterDecimalStyle;
|
||||
|
||||
NSNumber *numeric = [numberFormatter numberFromString:string];
|
||||
|
||||
|
||||
if (numeric) {
|
||||
date = [NSDate dateWithTimeIntervalSince1970:[numeric doubleValue]];
|
||||
} else if (![string isEqualToString:@""]) {
|
||||
if (![string isEqualToString:@""]) {
|
||||
for (NSFormatter *dateFormatter in self.objectMapping.dateFormatters) {
|
||||
BOOL success;
|
||||
@synchronized(dateFormatter) {
|
||||
|
||||
@@ -326,6 +326,12 @@ static NSDateFormatter *preferredDateFormatter = nil;
|
||||
defaultDateFormatters = [[NSMutableArray alloc] init];
|
||||
|
||||
// Setup the default formatters
|
||||
|
||||
//NSNumberFormatter which creates dates from Unix timestamps
|
||||
NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init];
|
||||
numberFormatter.numberStyle = NSNumberFormatterDecimalStyle;
|
||||
[self addDefaultDateFormatter:numberFormatter];
|
||||
|
||||
ISO8601DateFormatter *isoFormatter = [[ISO8601DateFormatter alloc] init];
|
||||
[self addDefaultDateFormatter:isoFormatter];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user