mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
improve sql parser performance
This commit is contained in:
@@ -204,24 +204,18 @@ public class MySqlLexer extends Lexer {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected final void scanString() {
|
||||
{
|
||||
boolean hasSpecial = false;
|
||||
int startIndex = pos + 1;
|
||||
int endIndex = indexOf('\'', startIndex);
|
||||
int endIndex = text.indexOf('\'', startIndex);
|
||||
if (endIndex == -1) {
|
||||
throw new ParserException("unclosed str");
|
||||
}
|
||||
|
||||
String stringVal = subString(startIndex, endIndex - startIndex);
|
||||
for (int i = 0; i < stringVal.length(); ++i) {
|
||||
char ch = stringVal.charAt(i);
|
||||
if (ch == '\\') {
|
||||
hasSpecial = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
hasSpecial = stringVal.indexOf('\\') != -1;
|
||||
|
||||
if (!hasSpecial) {
|
||||
this.stringVal = stringVal;
|
||||
|
||||
@@ -79,10 +79,6 @@ public class Lexer {
|
||||
return text.charAt(index);
|
||||
}
|
||||
|
||||
public final int indexOf(char ch, int fromIndex) {
|
||||
return text.indexOf(ch, fromIndex);
|
||||
}
|
||||
|
||||
public String addSymbol() {
|
||||
return subString(mark, bufPos);
|
||||
}
|
||||
@@ -248,6 +244,11 @@ public class Lexer {
|
||||
return;
|
||||
}
|
||||
|
||||
if (isFirstIdentifierChar(ch) && ch != 'N') {
|
||||
scanIdentifier();
|
||||
return;
|
||||
}
|
||||
|
||||
nextToken();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user