From 96160b1c2c8c9f12e18f22e94f4bb0aa981d67ee Mon Sep 17 00:00:00 2001 From: Paul Cacheux Date: Tue, 12 Nov 2024 12:59:15 +0100 Subject: [PATCH] implement allocation free fast path for `isBoolean` and `isNull` (#41) --- sqllexer_utils.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/sqllexer_utils.go b/sqllexer_utils.go index 24196fb..bbef75a 100644 --- a/sqllexer_utils.go +++ b/sqllexer_utils.go @@ -247,10 +247,20 @@ func isProcedure(token *Token) bool { } func isBoolean(ident string) bool { + // allocation free fast path for common cases + if ident == "true" || ident == "false" || ident == "TRUE" || ident == "FALSE" { + return true + } + return strings.ToUpper(ident) == "TRUE" || strings.ToUpper(ident) == "FALSE" } func isNull(ident string) bool { + // allocation free fast path for common cases + if ident == "null" || ident == "NULL" { + return true + } + return strings.ToUpper(ident) == "NULL" }