mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
improve SQL Visitor
This commit is contained in:
@@ -34,6 +34,7 @@ import static com.alibaba.druid.sql.parser.Token.RPAREN;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.BigInteger;
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* @author wenshao<szujobs@hotmail.com>
|
||||
@@ -85,6 +86,18 @@ public class Lexer {
|
||||
public final String subString(int offset, int count) {
|
||||
return text.substring(offset, offset + count);
|
||||
}
|
||||
|
||||
protected void initBuff(int size) {
|
||||
if (buf == null) {
|
||||
if (size < 32) {
|
||||
buf = new char[32];
|
||||
} else {
|
||||
buf = new char[size + 32];
|
||||
}
|
||||
} else if(buf.length < size) {
|
||||
buf = Arrays.copyOf(buf, size);
|
||||
}
|
||||
}
|
||||
|
||||
public void arraycopy(int srcPos, char[] dest, int destPos, int length) {
|
||||
text.getChars(srcPos, srcPos + length, dest, destPos);
|
||||
@@ -494,9 +507,7 @@ public class Lexer {
|
||||
break;
|
||||
} else {
|
||||
if (!hasSpecial) {
|
||||
if (buf == null) {
|
||||
buf = new char[32];
|
||||
}
|
||||
initBuff(bufPos);
|
||||
arraycopy(mark + 1, buf, 0, bufPos);
|
||||
hasSpecial = true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user