aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPSQLParser.m
diff options
context:
space:
mode:
authorrowanbeentje <rowan@beent.je>2009-09-01 00:23:01 +0000
committerrowanbeentje <rowan@beent.je>2009-09-01 00:23:01 +0000
commitb5ccc9bd71123ea6a45100c0353c40e42e489f3a (patch)
treef3fbc1e05f6e6e65031ed9e2970255127ff83687 /Source/SPSQLParser.m
parentb2d168940430f6ab55d0aa635d38bcae1b64fcdb (diff)
downloadsequelpro-b5ccc9bd71123ea6a45100c0353c40e42e489f3a.tar.gz
sequelpro-b5ccc9bd71123ea6a45100c0353c40e42e489f3a.tar.bz2
sequelpro-b5ccc9bd71123ea6a45100c0353c40e42e489f3a.zip
- Remove an NSLog I accidentally left in (and another found via a search)
- Improve SQL parser streaming improvements for significant speedups and some very important bugfixes
Diffstat (limited to 'Source/SPSQLParser.m')
-rw-r--r--Source/SPSQLParser.m28
1 files changed, 10 insertions, 18 deletions
diff --git a/Source/SPSQLParser.m b/Source/SPSQLParser.m
index a2fb2026..0b968d0a 100644
--- a/Source/SPSQLParser.m
+++ b/Source/SPSQLParser.m
@@ -218,9 +218,14 @@ TO_BUFFER_STATE to_scan_string (const char *);
{
long stringIndex;
NSString *resultString;
-
+
+ if (character != parsedToChar) {
+ parsedToChar = character;
+ parsedToPosition = -1;
+ }
+
// Get the first occurrence of the specified character, returning nil if it could not be found
- stringIndex = [self firstOccurrenceOfCharacter:character ignoringQuotedStrings:ignoreQuotedStrings];
+ stringIndex = [self firstOccurrenceOfCharacter:character afterIndex:parsedToPosition ignoringQuotedStrings:ignoreQuotedStrings];
if (stringIndex == NSNotFound) return nil;
// Select the appropriate string range, truncate the current string, and return the selected string
@@ -476,11 +481,7 @@ TO_BUFFER_STATE to_scan_string (const char *);
*/
- (long) firstOccurrenceOfCharacter:(unichar)character ignoringQuotedStrings:(BOOL)ignoreQuotedStrings
{
- if (character != parsedToChar) {
- parsedToChar = character;
- parsedToPosition = -1;
- }
- return [self firstOccurrenceOfCharacter:character afterIndex:parsedToPosition skippingBrackets:NO ignoringQuotedStrings:ignoreQuotedStrings];
+ return [self firstOccurrenceOfCharacter:character afterIndex:-1 skippingBrackets:NO ignoringQuotedStrings:ignoreQuotedStrings];
}
@@ -489,10 +490,6 @@ TO_BUFFER_STATE to_scan_string (const char *);
*/
- (long) firstOccurrenceOfCharacter:(unichar)character afterIndex:(long)startIndex ignoringQuotedStrings:(BOOL)ignoreQuotedStrings
{
- if (character != parsedToChar) {
- parsedToChar = '\0';
- parsedToPosition = -1;
- }
return [self firstOccurrenceOfCharacter:character afterIndex:startIndex skippingBrackets:NO ignoringQuotedStrings:ignoreQuotedStrings];
}
@@ -504,11 +501,6 @@ TO_BUFFER_STATE to_scan_string (const char *);
long stringLength = [string length];
int bracketingLevel = 0;
- if (character != parsedToChar) {
- parsedToChar = character;
- parsedToPosition = -1;
- }
-
// Cache frequently used selectors, avoiding dynamic binding overhead
IMP charAtIndex = [self methodForSelector:@selector(charAtIndex:)];
IMP endIndex = [self methodForSelector:@selector(endIndexOfStringQuotedByCharacter:startingAtIndex:)];
@@ -538,7 +530,7 @@ TO_BUFFER_STATE to_scan_string (const char *);
if (!ignoreQuotedStrings) break;
quotedStringEndIndex = (long)(*endIndex)(self, @selector(endIndexOfStringQuotedByCharacter:startingAtIndex:), currentCharacter, currentStringIndex+1);
if (quotedStringEndIndex == NSNotFound) {
- parsedToPosition = currentStringIndex;
+ parsedToPosition = stringLength - 1;
return NSNotFound;
}
currentStringIndex = quotedStringEndIndex;
@@ -903,8 +895,8 @@ TO_BUFFER_STATE to_scan_string (const char *);
}
- (id) initWithContentsOfFile:(id)path {
parsedToChar = '\0';
- parsedToPosition = 0;
parsedToPosition = -1;
+ charCacheEnd = -1;
return [self initWithContentsOfFile:path encoding:NSUTF8StringEncoding error:NULL];
}
- (id) initWithContentsOfFile:(NSString *)path encoding:(NSStringEncoding)encoding error:(NSError **)error {