提交 2943366e authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov

Use bitmask to reduce switch table size in readTermWithIdentifier()

上级 ed78fae8
...@@ -3881,9 +3881,15 @@ public class Parser { ...@@ -3881,9 +3881,15 @@ public class Parser {
private Expression readTermWithIdentifier(String name) { private Expression readTermWithIdentifier(String name) {
// Unquoted identifier is never empty // Unquoted identifier is never empty
char ch = name.charAt(0); char ch = name.charAt(0);
if (!identifiersToUpper) {
/*
* Convert a-z to A-Z. This method is safe, because only A-Z
* characters are considered below.
*/
ch &= 0xffdf;
}
switch (ch) { switch (ch) {
case 'A': case 'A':
case 'a':
if (equalsToken("ARRAY", name)) { if (equalsToken("ARRAY", name)) {
read(OPEN_BRACKET); read(OPEN_BRACKET);
ArrayList<Expression> list = Utils.newSmallArrayList(); ArrayList<Expression> list = Utils.newSmallArrayList();
...@@ -3898,7 +3904,6 @@ public class Parser { ...@@ -3898,7 +3904,6 @@ public class Parser {
} }
break; break;
case 'C': case 'C':
case 'c':
if (equalsToken("CURRENT_USER", name)) { if (equalsToken("CURRENT_USER", name)) {
return readFunctionWithoutParameters("USER"); return readFunctionWithoutParameters("USER");
} else if (database.getMode().getEnum() == ModeEnum.DB2 && equalsToken("CURRENT", name)) { } else if (database.getMode().getEnum() == ModeEnum.DB2 && equalsToken("CURRENT", name)) {
...@@ -3906,7 +3911,6 @@ public class Parser { ...@@ -3906,7 +3911,6 @@ public class Parser {
} }
break; break;
case 'D': case 'D':
case 'd':
if (currentTokenType == VALUE && currentValue.getType() == Value.STRING && if (currentTokenType == VALUE && currentValue.getType() == Value.STRING &&
(equalsToken("DATE", name) || equalsToken("D", name))) { (equalsToken("DATE", name) || equalsToken("D", name))) {
String date = currentValue.getString(); String date = currentValue.getString();
...@@ -3915,7 +3919,6 @@ public class Parser { ...@@ -3915,7 +3919,6 @@ public class Parser {
} }
break; break;
case 'E': case 'E':
case 'e':
if (currentTokenType == VALUE && currentValue.getType() == Value.STRING && equalsToken("E", name)) { if (currentTokenType == VALUE && currentValue.getType() == Value.STRING && equalsToken("E", name)) {
String text = currentValue.getString(); String text = currentValue.getString();
// the PostgreSQL ODBC driver uses // the PostgreSQL ODBC driver uses
...@@ -3928,13 +3931,11 @@ public class Parser { ...@@ -3928,13 +3931,11 @@ public class Parser {
} }
break; break;
case 'I': case 'I':
case 'i':
if (equalsToken("INTERVAL", name)) { if (equalsToken("INTERVAL", name)) {
return readInterval(); return readInterval();
} }
break; break;
case 'N': case 'N':
case 'n':
if (equalsToken("NEXT", name) && readIf("VALUE")) { if (equalsToken("NEXT", name) && readIf("VALUE")) {
read(FOR); read(FOR);
return new SequenceValue(readSequence()); return new SequenceValue(readSequence());
...@@ -3946,7 +3947,6 @@ public class Parser { ...@@ -3946,7 +3947,6 @@ public class Parser {
} }
break; break;
case 'S': case 'S':
case 's':
if (equalsToken("SYSDATE", name)) { if (equalsToken("SYSDATE", name)) {
return readFunctionWithoutParameters("CURRENT_TIMESTAMP"); return readFunctionWithoutParameters("CURRENT_TIMESTAMP");
} else if (equalsToken("SYSTIME", name)) { } else if (equalsToken("SYSTIME", name)) {
...@@ -3956,7 +3956,6 @@ public class Parser { ...@@ -3956,7 +3956,6 @@ public class Parser {
} }
break; break;
case 'T': case 'T':
case 't':
if (equalsToken("TIME", name)) { if (equalsToken("TIME", name)) {
boolean without = readIf("WITHOUT"); boolean without = readIf("WITHOUT");
if (without) { if (without) {
...@@ -4009,7 +4008,6 @@ public class Parser { ...@@ -4009,7 +4008,6 @@ public class Parser {
} }
break; break;
case 'X': case 'X':
case 'x':
if (currentTokenType == VALUE && currentValue.getType() == Value.STRING && equalsToken("X", name)) { if (currentTokenType == VALUE && currentValue.getType() == Value.STRING && equalsToken("X", name)) {
byte[] buffer = StringUtils.convertHexToBytes(currentValue.getString()); byte[] buffer = StringUtils.convertHexToBytes(currentValue.getString());
read(); read();
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论