use .eq_ignore_ascii_case() to avoid allocating

This commit is contained in:
Damien Elmes 2020-03-17 12:34:39 +10:00
parent 68657c7166
commit dcb2b46d1b

View file

@ -191,9 +191,9 @@ fn unquoted_term(s: &str) -> IResult<&str, Node> {
map_res( map_res(
take_while1(|c| c != ' ' && c != ')'), take_while1(|c| c != ' ' && c != ')'),
|text: &str| -> ParseResult<Node> { |text: &str| -> ParseResult<Node> {
Ok(if text.len() == 2 && text.to_ascii_lowercase() == "or" { Ok(if text.eq_ignore_ascii_case("or") {
Node::Or Node::Or
} else if text.len() == 3 && text.to_ascii_lowercase() == "and" { } else if text.eq_ignore_ascii_case("and") {
Node::And Node::And
} else { } else {
Node::Search(search_node_for_text(text)?) Node::Search(search_node_for_text(text)?)