Use binary search to speed up matching keywords (#191)

This commit is contained in:
Daniël Heres 2020-06-07 19:25:10 +02:00 committed by GitHub
parent af54eb02b2
commit a42121de52
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 27 additions and 18 deletions

View file

@ -21,6 +21,7 @@
use matches::assert_matches;
use sqlparser::ast::*;
use sqlparser::dialect::keywords::ALL_KEYWORDS;
use sqlparser::parser::*;
use sqlparser::test_utils::{all_dialects, expr_from_projection, number, only};
@ -2851,6 +2852,14 @@ fn parse_drop_index() {
}
}
#[test]
fn keywords_sorted() {
// assert!(ALL_KEYWORDS.is_sorted())
let mut copy = Vec::from(ALL_KEYWORDS);
copy.sort();
assert!(copy == ALL_KEYWORDS)
}
fn parse_sql_statements(sql: &str) -> Result<Vec<Statement>, ParserError> {
all_dialects().parse_sql_statements(sql)
}