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:
Stephan Diederich
2012-09-14 16:19:51 +02:00
parent 89fd9d2b95
commit 6e4b1a1600
2 changed files with 7 additions and 9 deletions

View File

@@ -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) {

View File

@@ -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];