aboutsummaryrefslogtreecommitdiffstats
path: root/Source/TableSource.m
diff options
context:
space:
mode:
authorBibiko <bibiko@eva.mpg.de>2009-06-21 17:49:57 +0000
committerBibiko <bibiko@eva.mpg.de>2009-06-21 17:49:57 +0000
commitb42de63e19756c8769d0dad3e1ebc13b01ad0540 (patch)
tree607a79ce14ef69598dc4d75334aded6829bd03a6 /Source/TableSource.m
parent8fad8578072ae3f3244071e4a4debd07f34b2e9c (diff)
downloadsequelpro-b42de63e19756c8769d0dad3e1ebc13b01ad0540.tar.gz
sequelpro-b42de63e19756c8769d0dad3e1ebc13b01ad0540.tar.bz2
sequelpro-b42de63e19756c8769d0dad3e1ebc13b01ad0540.zip
• some code cleaning and tiny performance enhancements for various for/while loops
Diffstat (limited to 'Source/TableSource.m')
-rw-r--r--Source/TableSource.m15
1 files changed, 9 insertions, 6 deletions
diff --git a/Source/TableSource.m b/Source/TableSource.m
index e9c416cf..24fd13a5 100644
--- a/Source/TableSource.m
+++ b/Source/TableSource.m
@@ -544,22 +544,25 @@ fetches the result as an array with a dictionary for each row in it
*/
- (NSArray *)fetchResultAsArray:(CMMCPResult *)theResult
{
- NSMutableArray *tempResult = [NSMutableArray array];
+ unsigned long numOfRows = [theResult numOfRows];
+ NSMutableArray *tempResult = [NSMutableArray arrayWithCapacity:numOfRows];
NSMutableDictionary *tempRow;
NSArray *keys;
id key;
int i;
+ Class nullClass = [NSNull class];
+ id prefsNullValue = [prefs objectForKey:@"NullValue"];
- if ([theResult numOfRows]) [theResult dataSeek:0];
- for ( i = 0 ; i < [theResult numOfRows] ; i++ ) {
+ if (numOfRows) [theResult dataSeek:0];
+ for ( i = 0 ; i < numOfRows ; i++ ) {
tempRow = [NSMutableDictionary dictionaryWithDictionary:[theResult fetchRowAsDictionary]];
//use NULL string from preferences instead of the NSNull oject returned by the framework
keys = [tempRow allKeys];
for (int i = 0; i < [keys count] ; i++) {
- key = [keys objectAtIndex:i];
- if ( [[tempRow objectForKey:key] isMemberOfClass:[NSNull class]] )
- [tempRow setObject:[prefs objectForKey:@"NullValue"] forKey:key];
+ key = NSArrayObjectAtIndex(keys, i);
+ if ( [[tempRow objectForKey:key] isMemberOfClass:nullClass] )
+ [tempRow setObject:prefsNullValue forKey:key];
}
// change some fields to be more human-readable or GUI compatible
if ( [[tempRow objectForKey:@"Extra"] isEqualToString:@""] ) {