aboutsummaryrefslogtreecommitdiffstats
path: root/Frameworks/SPMySQLFramework/Source/SPMySQLResult.m
diff options
context:
space:
mode:
authorrowanbeentje <rowan@beent.je>2012-02-24 00:30:18 +0000
committerrowanbeentje <rowan@beent.je>2012-02-24 00:30:18 +0000
commit0c91f439a5b23e1b5a6d8139eb47aa5694e2925f (patch)
treec6d5b81773bfa78458dc249d582b04066f2c4373 /Frameworks/SPMySQLFramework/Source/SPMySQLResult.m
parent05f1612cbb7e33cf9135a346fc2505cc0e87e853 (diff)
downloadsequelpro-0c91f439a5b23e1b5a6d8139eb47aa5694e2925f.tar.gz
sequelpro-0c91f439a5b23e1b5a6d8139eb47aa5694e2925f.tar.bz2
sequelpro-0c91f439a5b23e1b5a6d8139eb47aa5694e2925f.zip
Improvements to SPMySQL framework:
- Correctly record affected rows - Fix thread safety/autorelease issues when draining pools during fast iteration - Improve streaming result processing speed
Diffstat (limited to 'Frameworks/SPMySQLFramework/Source/SPMySQLResult.m')
-rw-r--r--Frameworks/SPMySQLFramework/Source/SPMySQLResult.m13
1 files changed, 9 insertions, 4 deletions
diff --git a/Frameworks/SPMySQLFramework/Source/SPMySQLResult.m b/Frameworks/SPMySQLFramework/Source/SPMySQLResult.m
index b110958d..3ccd5727 100644
--- a/Frameworks/SPMySQLFramework/Source/SPMySQLResult.m
+++ b/Frameworks/SPMySQLFramework/Source/SPMySQLResult.m
@@ -32,8 +32,10 @@
#import "SPMySQLResult.h"
#import "SPMySQL Private APIs.h"
+#import "SPMySQLArrayAdditions.h"
static SPMySQLResultFieldProcessor fieldProcessingMap[256];
+static id NSNullPointer;
@implementation SPMySQLResult
@@ -52,6 +54,9 @@ static SPMySQLResultFieldProcessor fieldProcessingMap[256];
+ (void)initialize
{
+ // Cached NSNull singleton reference
+ if (!NSNullPointer) NSNullPointer = [NSNull null];
+
// Go through the list of enum_field_types in mysql_com.h, mapping each to the method for
// processing that result set.
fieldProcessingMap[MYSQL_TYPE_DECIMAL] = SPMySQLResultFieldAsString;
@@ -266,11 +271,11 @@ static SPMySQLResultFieldProcessor fieldProcessingMap[256];
id cellData = SPMySQLResultGetObject(self, theRow[i], theRowDataLengths[i], fieldTypes[i], i);
// If object creation failed, display a null
- if (!cellData) cellData = [NSNull null];
+ if (!cellData) cellData = NSNullPointer;
// Add to the result array/dictionary
if (theType == SPMySQLResultRowAsArray) {
- [(NSMutableArray *)theReturnData addObject:cellData];
+ SPMySQLMutableArrayInsertObject(theReturnData, cellData, i);
} else {
[(NSMutableDictionary *)theReturnData setObject:cellData forKey:fieldNames[i]];
}
@@ -389,7 +394,7 @@ static SPMySQLResultFieldProcessor fieldProcessingMap[256];
{
// A NULL pointer for the data indicates a null value; return a NSNull object.
- if (bytes == NULL) return [NSNull null];
+ if (bytes == NULL) return NSNullPointer;
// Determine the field processor to use
SPMySQLResultFieldProcessor dataProcessor = fieldProcessingMap[fieldType];
@@ -445,7 +450,7 @@ static SPMySQLResultFieldProcessor fieldProcessingMap[256];
// Convert null types to NSNulls
case SPMySQLResultFieldAsNull:
- return [NSNull null];
+ return NSNullPointer;
case SPMySQLResultFieldAsUnhandled:
NSLog(@"SPMySQLResult processing encountered an unknown field type (%d), falling back to NSData handling", fieldType);