Permalink
Browse files

perf: reduce memory allocations when JDBC escapes ({fn ...}) are used

Avoid SqlParseState.values() in Parser as it always allocates an array

see #1229
  • Loading branch information...
benbenw authored and vlsi committed Jun 28, 2018
1 parent b7fd9f3 commit 2a1e09100c4d56a37c84668135ec7fe3e05962cb
Showing with 3 additions and 1 deletion.
  1. +3 −1 pgjdbc/src/main/java/org/postgresql/core/Parser.java
@@ -1157,7 +1157,7 @@ private static int parseSql(char[] p_sql, int i, StringBuilder newsql, boolean s
break;
} else if (c == '{') { // start of an escape code?
if (i + 1 < len) {
SqlParseState[] availableStates = SqlParseState.values();
SqlParseState[] availableStates = SqlParseState.VALUES;
// skip first state, it's not a escape code state
for (int j = 1; j < availableStates.length; j++) {
SqlParseState availableState = availableStates[j];
@@ -1292,6 +1292,8 @@ private static String escapeFunction(String functionName, String args, boolean s
ESC_OUTERJOIN("oj", QUOTE_OR_ALPHABETIC_MARKER_OR_PARENTHESIS, null),
ESC_ESCAPECHAR("escape", SINGLE_QUOTE, "ESCAPE ");
private static final SqlParseState[] VALUES = values();
private final char[] escapeKeyword;
private final char[] allowedValues;
private final String replacementKeyword;

0 comments on commit 2a1e091

Please sign in to comment.