From d702a0175e62dfa80537f2405c185d21b739883f Mon Sep 17 00:00:00 2001 From: stuconnolly Date: Thu, 6 Sep 2012 11:04:43 +0000 Subject: When retrieving the value of a column only lookup the type once. --- Frameworks/PostgresKit/Source/FLXPostgresResult.m | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'Frameworks/PostgresKit') diff --git a/Frameworks/PostgresKit/Source/FLXPostgresResult.m b/Frameworks/PostgresKit/Source/FLXPostgresResult.m index 62e0d222..1aaeb1de 100644 --- a/Frameworks/PostgresKit/Source/FLXPostgresResult.m +++ b/Frameworks/PostgresKit/Source/FLXPostgresResult.m @@ -31,7 +31,7 @@ static NSString *FLXPostgresResultError = @"FLXPostgresResultError"; - (void)_populateFields; - (id)_objectForRow:(unsigned int)row column:(unsigned int)column; -- (id )_typeHandlerForColumn:(unsigned int)column; +- (id )_typeHandlerForColumn:(unsigned int)column withType:(FLXPostgresOid)type; @end @@ -204,13 +204,12 @@ static NSString *FLXPostgresResultError = @"FLXPostgresResultError"; if (PQgetisnull(_result, row, column)) return [NSNull null]; // Get bytes and length + FLXPostgresOid type = PQftype(_result, column); const void *bytes = PQgetvalue(_result, row, column); - NSUInteger length = PQgetlength(_result, row, column); - FLXPostgresOid type = PQftype(_result, column); // Get handler for this type - id handler = [self _typeHandlerForColumn:column]; + id handler = [self _typeHandlerForColumn:column withType:type]; if (!handler) { NSLog(@"PostgresKit: Warning: No type handler found for type %d, return NSData.", type); @@ -228,15 +227,13 @@ static NSString *FLXPostgresResultError = @"FLXPostgresResultError"; * * @return The type handler or nil if out of this result's range. */ -- (id )_typeHandlerForColumn:(unsigned int)column +- (id )_typeHandlerForColumn:(unsigned int)column withType:(FLXPostgresOid)type { if (column >= _numberOfFields) return nil; id handler = _typeHandlers[column]; - if (!handler) { - FLXPostgresOid type = PQftype(_result, column); - + if (!handler) { _typeHandlers[column] = [_connection typeHandlerForRemoteType:type]; handler = _typeHandlers[column]; -- cgit v1.2.3