diff options
author | rowanbeentje <rowan@beent.je> | 2012-03-05 21:52:01 +0000 |
---|---|---|
committer | rowanbeentje <rowan@beent.je> | 2012-03-05 21:52:01 +0000 |
commit | d5e20720cf7f991a691d9a03e7f895211b7c98ad (patch) | |
tree | 084208404fd826b53f1754f87ec30bae3d6b35cb /Source | |
parent | 0c91f439a5b23e1b5a6d8139eb47aa5694e2925f (diff) | |
parent | 69db4915523c4c6cc2d8138a72456cb23f47b7ec (diff) | |
download | sequelpro-d5e20720cf7f991a691d9a03e7f895211b7c98ad.tar.gz sequelpro-d5e20720cf7f991a691d9a03e7f895211b7c98ad.tar.bz2 sequelpro-d5e20720cf7f991a691d9a03e7f895211b7c98ad.zip |
- Bring SPMySQL Framework integration branch up to date with trunk
Diffstat (limited to 'Source')
-rw-r--r-- | Source/SPArrayAdditions.h | 36 | ||||
-rw-r--r-- | Source/SPExtendedTableInfo.h | 2 | ||||
-rw-r--r-- | Source/SPNarrowDownCompletion.m | 7 | ||||
-rw-r--r-- | Source/SPTableTriggers.m | 2 |
4 files changed, 43 insertions, 4 deletions
diff --git a/Source/SPArrayAdditions.h b/Source/SPArrayAdditions.h index e08bfa33..abeec095 100644 --- a/Source/SPArrayAdditions.h +++ b/Source/SPArrayAdditions.h @@ -27,9 +27,41 @@ static inline id NSArrayObjectAtIndex(NSArray *self, NSUInteger i) return (id)CFArrayGetValueAtIndex((CFArrayRef)self, (long)i); } -static inline void NSMutableArrayAddObject(NSArray *self, id anObject) +/** + * Set up a static function to allow fast mutable array insertion using + * cached selectors. + * At least in 10.7, inserting items into an array at a known point + * using NSMutableArray methods appears to be the fastest way of adding + * items to a CF/NSMutableArray. + */ +static inline void NSMutableArrayInsertObject(NSMutableArray *self, id anObject, NSUInteger anIndex) { - CFArrayAppendValue((CFMutableArrayRef)self, anObject); + typedef id (*NSMutableArrayInsertObjectPtr)(NSMutableArray*, SEL, id, NSUInteger); + static NSMutableArrayInsertObjectPtr cachedMethodPointer; + static SEL cachedSelector; + + if (!cachedSelector) cachedSelector = @selector(insertObject:atIndex:); + if (!cachedMethodPointer) cachedMethodPointer = (NSMutableArrayInsertObjectPtr)[self methodForSelector:cachedSelector]; + + cachedMethodPointer(self, cachedSelector, anObject, anIndex); +} +/** + * Set up a static function to allow fast mutable array insertion using + * cached selectors. + * At least in 10.7, adding items to an array using NSMutableArray methods + * appears to be the fastest approach to adding items to a CF/NSMutableArray; + * only NSMutableArrayInsertObject is faster if the position is known. + */ +static inline void NSMutableArrayAddObject(NSMutableArray *self, id anObject) +{ + typedef id (*NSMutableArrayAddObjectPtr)(NSMutableArray*, SEL, id); + static NSMutableArrayAddObjectPtr cachedMethodPointer; + static SEL cachedSelector; + + if (!cachedSelector) cachedSelector = @selector(addObject:); + if (!cachedMethodPointer) cachedMethodPointer = (NSMutableArrayAddObjectPtr)[self methodForSelector:cachedSelector]; + + cachedMethodPointer(self, cachedSelector, anObject); } static inline void NSMutableArrayReplaceObject(NSArray *self, CFIndex idx, id anObject) diff --git a/Source/SPExtendedTableInfo.h b/Source/SPExtendedTableInfo.h index dfe6a9e0..72087f67 100644 --- a/Source/SPExtendedTableInfo.h +++ b/Source/SPExtendedTableInfo.h @@ -58,7 +58,7 @@ SPMySQLConnection *connection; } -@property (readwrite, assign) SPMySQLConnection *connection; +@property (readwrite, retain) SPMySQLConnection *connection; // IBAction methods - (IBAction)reloadTable:(id)sender; diff --git a/Source/SPNarrowDownCompletion.m b/Source/SPNarrowDownCompletion.m index abc40a4e..5e7b5320 100644 --- a/Source/SPNarrowDownCompletion.m +++ b/Source/SPNarrowDownCompletion.m @@ -171,6 +171,13 @@ - (void)close { + + // Invalidate the timer now to prevent retain cycles preventing deallocation + if (stateTimer != nil) { + [stateTimer invalidate]; + [stateTimer release]; + } + closeMe = YES; [theView setCompletionIsOpen:NO]; [super close]; diff --git a/Source/SPTableTriggers.m b/Source/SPTableTriggers.m index 715498bb..393b0568 100644 --- a/Source/SPTableTriggers.m +++ b/Source/SPTableTriggers.m @@ -352,7 +352,7 @@ static const NSString *SPTriggerSQLMode = @"TriggerSQLMode"; if ([tableDocumentInstance isWorking]) return NO; // Start Edit panel - if (([triggerData count] > rowIndex) && [triggerData objectAtIndex:rowIndex]) { + if (((NSInteger)[triggerData count] > rowIndex) && [triggerData objectAtIndex:rowIndex]) { [self _editTriggerAtIndex:rowIndex]; } |