diff options
author | Bibiko <bibiko@eva.mpg.de> | 2009-06-18 12:12:52 +0000 |
---|---|---|
committer | Bibiko <bibiko@eva.mpg.de> | 2009-06-18 12:12:52 +0000 |
commit | 83c9f9df7da331460c8511c145d181e3a98e30f0 (patch) | |
tree | daaf1be4c70c9041bcb3c26756735e7fb680ef85 /Source | |
parent | a433ccb9b6ddc8de78d06629356d77e657fbc137 (diff) | |
download | sequelpro-83c9f9df7da331460c8511c145d181e3a98e30f0.tar.gz sequelpro-83c9f9df7da331460c8511c145d181e3a98e30f0.tar.bz2 sequelpro-83c9f9df7da331460c8511c145d181e3a98e30f0.zip |
• further tiny improvements for queryString's speed
- cStringFromString function pointer is cached
- if utf8 encoding make usage of UTF8String but implemented inside of queryString (otherwise no effect)
• tiny code cosmetics
Diffstat (limited to 'Source')
-rw-r--r-- | Source/CMMCPConnection.h | 1 | ||||
-rw-r--r-- | Source/CMMCPConnection.m | 18 |
2 files changed, 15 insertions, 4 deletions
diff --git a/Source/CMMCPConnection.h b/Source/CMMCPConnection.h index 26590d85..4005c19b 100644 --- a/Source/CMMCPConnection.h +++ b/Source/CMMCPConnection.h @@ -76,6 +76,7 @@ BOOL delegateResponseToWillQueryString; BOOL consoleLoggingEnabled; + IMP cStringPtr; IMP willQueryStringPtr; } diff --git a/Source/CMMCPConnection.m b/Source/CMMCPConnection.m index b976c3a7..bf3eac18 100644 --- a/Source/CMMCPConnection.m +++ b/Source/CMMCPConnection.m @@ -138,6 +138,8 @@ static void forcePingTimeout(int signalNumber); if (![NSBundle loadNibNamed:@"ConnectionErrorDialog" owner:self]) { NSLog(@"Connection error dialog could not be loaded; connection failure handling will not function correctly."); } + + cStringPtr = [self methodForSelector:@selector(cStringFromString:usingEncoding:)]; } /* @@ -746,9 +748,17 @@ static void forcePingTimeout(int signalNumber); (void)(NSString*)(*willQueryStringPtr)(delegate, @selector(willQueryString:), query); // Derive the query string in the correct encoding - theCQuery = [self cStringFromString:query usingEncoding:encoding]; - // Set the length of the current query + 1 (\0) - theCQueryLength = strlen(theCQuery)+1; + switch(encoding) { + case NSUTF8StringEncoding: + theCQuery = [query UTF8String]; + break; + default: + theCQuery = (const char*)(NSString*)(int)(*cStringPtr)(self, @selector(cStringFromString:), query, encoding); + //[self cStringFromString:query usingEncoding:encoding]; + } + + // Set the length of the current query + theCQueryLength = strlen(theCQuery); // Check query length against max_allowed_packet; if it is larger, the // query would error, so if max_allowed_packet is editable for the user @@ -849,7 +859,7 @@ static void forcePingTimeout(int signalNumber); lastQueryAffectedRows = queryAffectedRows; // If an error occurred, inform the delegate - if (0 != queryResultCode && delegate && [delegate respondsToSelector:@selector(queryGaveError:)]) + if (queryResultCode & delegateResponseToWillQueryString) [delegate queryGaveError:lastQueryErrorMessage]; [self startKeepAliveTimerResettingState:YES]; |