Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions docs/changelog/126578.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pr: 126578
summary: Retrieve token text only when necessary
area: ES|QL
type: bug
issues: []
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,10 @@ public static String text(ParseTree node) {
*/
public static String nameOrPosition(Token token) {
int tokenType = token.getType();
String s = token.getText();
// Retrieve text from the token only when necessary, when the token type is known.
return switch (tokenType) {
case EsqlBaseLexer.NAMED_OR_POSITIONAL_PARAM -> s.substring(SINGLE_PARAM);
case EsqlBaseLexer.NAMED_OR_POSITIONAL_DOUBLE_PARAMS -> s.substring(DOUBLE_PARAM);
case EsqlBaseLexer.NAMED_OR_POSITIONAL_PARAM -> token.getText().substring(SINGLE_PARAM);
case EsqlBaseLexer.NAMED_OR_POSITIONAL_DOUBLE_PARAMS -> token.getText().substring(DOUBLE_PARAM);
default -> EMPTY;
};
}
Expand Down
Loading