You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@datafusion.apache.org by "andygrove (via GitHub)" <gi...@apache.org> on 2026/01/23 15:04:02 UTC
[PR] perf: optimize `make_word()` to avoid unnecessary allocations [datafusion-sqlparser-rs]
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: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] perf: optimize `make_word()` to avoid unnecessary allocations [datafusion-sqlparser-rs]
Posted by "iffyio (via GitHub)" <gi...@apache.org>.
iffyio merged PR #2176:
URL: https://github.com/apache/datafusion-sqlparser-rs/pull/2176
--
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: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org