diff options
author | Bibiko <bibiko@eva.mpg.de> | 2010-08-20 10:02:00 +0000 |
---|---|---|
committer | Bibiko <bibiko@eva.mpg.de> | 2010-08-20 10:02:00 +0000 |
commit | d17a6b638e529694685a333162bbf6fec6c7fc08 (patch) | |
tree | 5c72506af7bf75299c093ce6a47b7cc4a956e0ff /Source/SPDataAdditions.m | |
parent | dabf6466f11e5936ee871b8b3dd573020a142586 (diff) | |
download | sequelpro-d17a6b638e529694685a333162bbf6fec6c7fc08.tar.gz sequelpro-d17a6b638e529694685a333162bbf6fec6c7fc08.tar.bz2 sequelpro-d17a6b638e529694685a333162bbf6fec6c7fc08.zip |
• overall replacement of:
[aString appendString:[NSString stringWithFormat:]] by
[aString appendFormat:]
since it's much more faster
• first look at loop where several [aStr appendString:] occur to try to combine them into one appendString or appendFormat since the allocation of memory takes really time
Note: I tested all my changes but we should test it further to be sure that I didn't a mistake!
Diffstat (limited to 'Source/SPDataAdditions.m')
-rw-r--r-- | Source/SPDataAdditions.m | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/Source/SPDataAdditions.m b/Source/SPDataAdditions.m index b8f4ee3a..b482357a 100644 --- a/Source/SPDataAdditions.m +++ b/Source/SPDataAdditions.m @@ -285,7 +285,7 @@ static char base64encodingTable[64] = { NSUInteger buffLength = bytesPerLine; // add hex value of location - [location appendString:[NSString stringWithFormat:@"%X", i]]; + [location appendFormat:@"%X", i]; // pad it while( longest > [location length] ) { @@ -304,7 +304,7 @@ static char base64encodingTable[64] = { // build the hex string for ( j = 0; j < buffLength; j++ ) { - [hex appendString:[NSString stringWithFormat:@"%02X ", *(buffer + j)]]; + [hex appendFormat:@"%02X ", *(buffer + j)]; // Replace non-displayed bytes by '.' // non-displayed bytes are all bytes whose hex code is less than 0x20 @@ -320,7 +320,7 @@ static char base64encodingTable[64] = { } // build line - [retVal appendFormat:@"%@ %@ %@\n", location, hex, [NSString stringWithFormat:@"%s", buffer]]; + [retVal appendFormat:@"%@ %@ %s\n", location, hex, buffer]; // clean up [hex release]; @@ -338,20 +338,19 @@ static char base64encodingTable[64] = { */ - (NSString *) shortStringRepresentationUsingEncoding:(NSStringEncoding)encoding { - NSString *tmp = [[NSString alloc] initWithData:self encoding:encoding]; - NSString *shortString; + NSString *tmp = [[[NSString alloc] initWithData:self encoding:encoding] autorelease]; + if (tmp == nil) tmp = [[NSString alloc] initWithData:self encoding:NSASCIIStringEncoding]; if (tmp == nil) return @"- cannot be displayed -"; else { - if([tmp length]>255) - shortString = [[NSString stringWithString:tmp] substringToIndex:255]; + if([tmp length] > 255) + return [tmp substringToIndex:255]; else - shortString = [NSString stringWithString:tmp]; + return tmp; } - [tmp release]; - return shortString; + return @"- cannot be displayed -"; } @end |