mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-08-18 13:10:15 +00:00
Use binary search to speed up matching keywords (#191)
This commit is contained in:
parent
af54eb02b2
commit
a42121de52
3 changed files with 27 additions and 18 deletions
|
@ -143,10 +143,9 @@ impl Token {
|
|||
}
|
||||
pub fn make_word(word: &str, quote_style: Option<char>) -> Self {
|
||||
let word_uppercase = word.to_uppercase();
|
||||
//TODO: need to reintroduce FnvHashSet at some point .. iterating over keywords is
|
||||
// not fast but I want the simplicity for now while I experiment with pluggable
|
||||
// dialects
|
||||
let is_keyword = quote_style == None && ALL_KEYWORDS.contains(&word_uppercase.as_str());
|
||||
//TODO: validate use of a hashset (e.g. FnvHashSet) compared to using binary search
|
||||
let is_keyword =
|
||||
quote_style == None && ALL_KEYWORDS.binary_search(&word_uppercase.as_str()).is_ok();
|
||||
Token::Word(Word {
|
||||
value: word.to_string(),
|
||||
quote_style,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue