diff options
author | Bibiko <bibiko@eva.mpg.de> | 2009-06-18 14:03:02 +0000 |
---|---|---|
committer | Bibiko <bibiko@eva.mpg.de> | 2009-06-18 14:03:02 +0000 |
commit | c040e154bc58fac262324a0c40ef5572d5ef28c8 (patch) | |
tree | 700162d14e8f27601c21eb3014f67e8df2a20b06 /Source/SPStringAdditions.h | |
parent | 189886df88e04296555743b15ba31d2fee887e22 (diff) | |
download | sequelpro-c040e154bc58fac262324a0c40ef5572d5ef28c8.tar.gz sequelpro-c040e154bc58fac262324a0c40ef5572d5ef28c8.tar.bz2 sequelpro-c040e154bc58fac262324a0c40ef5572d5ef28c8.zip |
• introduced inline function NSStringUTF8String() to SPStringAdditions.h
- NSData *d = [aStr UTF8String]; :== NSData *d = NSStrignUTF8String(aStr) but a tick faster
• implemented NSStringUTF8String() in queryString: and for the lex parser (syntax highlighting)
Diffstat (limited to 'Source/SPStringAdditions.h')
-rw-r--r-- | Source/SPStringAdditions.h | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/Source/SPStringAdditions.h b/Source/SPStringAdditions.h index 318e8d4d..3b6805e2 100644 --- a/Source/SPStringAdditions.h +++ b/Source/SPStringAdditions.h @@ -25,6 +25,20 @@ #import <Cocoa/Cocoa.h> +/* + * NSStringUTF8String(@"a String") function can be used to speed up + * the convertion from a NSString to NSData or const char* resp. + * NSData *d = [aStr UTF8String]; :== NSData *d = NSStringUTF8String(aStr); + */ +static inline const char* NSStringUTF8String(NSString* self) { + typedef const char* (*SPUTF8StringMethodPtr)(NSString*, SEL); + static SPUTF8StringMethodPtr SPNSStringGetUTF8String; + if (!SPNSStringGetUTF8String) SPNSStringGetUTF8String = (SPUTF8StringMethodPtr)[NSString instanceMethodForSelector:@selector(UTF8String)]; + const char* to_return = SPNSStringGetUTF8String(self, @selector(UTF8String)); + return to_return; +} + + @interface NSString (SPStringAdditions) + (NSString *)stringForByteSize:(int)byteSize; |