andygrove opened a new pull request, #2176:
URL: https://github.com/apache/datafusion-sqlparser-rs/pull/2176
## Summary
Optimizes the `Token::make_word()` function which is called for every
identifier and keyword token during tokenization.
**Changes:**
- Skip uppercase string allocation entirely for quoted identifiers (e.g.,
`"myColumn"`, `` `table` ``) since they are never keywords
- Use `to_ascii_uppercase()` instead of `to_uppercase()` since SQL keywords
are ASCII-only, avoiding Unicode case conversion overhead
**Before:**
```rust
let word_uppercase = word.to_uppercase(); // Always allocated
Token::Word(Word {
value: word.to_string(),
keyword: if quote_style.is_none() { /* lookup */ } else {
Keyword::NoKeyword },
})
```
**After:**
```rust
let keyword = if quote_style.is_none() {
let word_uppercase = word.to_ascii_uppercase(); // Only when needed
// lookup
} else {
Keyword::NoKeyword
};
Token::Word(Word { value: word.to_string(), keyword })
```
## Test plan
- [x] All existing tests pass
- [x] `cargo clippy` passes
🤖 Generated with [Claude Code](https://claude.ai/code)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]