improve sql parser performance

This commit is contained in:
wenshao
2013-01-14 20:45:13 +08:00
parent cb45e49a0c
commit 7aa2038498
6 changed files with 71 additions and 21 deletions
@@ -209,13 +209,24 @@ public class MySqlLexer extends Lexer {
{
boolean hasSpecial = false;
int startIndex = pos + 1;
int endIndex = text.indexOf('\'', startIndex);
int endIndex = -1; //text.indexOf('\'', startIndex);
for (int i = startIndex; i < text.length(); ++i) {
final char ch = text.charAt(i);
if (ch == '\\') {
hasSpecial = true;
}
if (ch == '\'') {
endIndex = i;
break;
}
}
if (endIndex == -1) {
throw new ParserException("unclosed str");
}
String stringVal = subString(startIndex, endIndex - startIndex);
hasSpecial = stringVal.indexOf('\\') != -1;
// hasSpecial = stringVal.indexOf('\\') != -1;
if (!hasSpecial) {
this.stringVal = stringVal;