Skip to content

Commit

Permalink
quick check for ascii letter
Browse files Browse the repository at this point in the history
  • Loading branch information
lu-zhengda committed Dec 16, 2024
1 parent 06a308b commit 90812ab
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions sqllexer_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,11 +198,17 @@ func isLeadingSign(ch rune) bool {
}

func isLetter(ch rune) bool {
return unicode.IsLetter(ch) || ch == '_'
// Fast path: ASCII letters and underscore
if ch <= 127 {
return (ch >= 'A' && ch <= 'Z') || (ch >= 'a' && ch <= 'z') || ch == '_'
}
// Fallback to Unicode
return unicode.IsLetter(ch)
}

func isAlphaNumeric(ch rune) bool {
return isLetter(ch) || isDigit(ch)
// Check if it's a digit first, then letter (faster for numbers)
return isDigit(ch) || isLetter(ch)
}

func isDoubleQuote(ch rune) bool {
Expand Down

0 comments on commit 90812ab

Please sign in to comment.