perf: reorder expensive conditional operand

This commit is contained in:
Will Lillis 2025-07-10 17:15:16 -04:00
parent ad0f953c21
commit 5ed2c77b59

View file

@ -238,13 +238,14 @@ pub(crate) fn parse_grammar(input: &str) -> ParseGrammarResult<InputGrammar> {
let mut in_progress = HashSet::new(); let mut in_progress = HashSet::new();
for (name, rule) in &rules { for (name, rule) in &rules {
if !variable_is_used( if grammar_json.word.as_ref().is_none_or(|w| w != name)
&rules, && !variable_is_used(
&extra_symbols, &rules,
&external_tokens, &extra_symbols,
name, &external_tokens,
&mut in_progress, name,
) && grammar_json.word.as_ref().is_none_or(|w| w != name) &mut in_progress,
)
{ {
grammar_json.conflicts.retain(|r| !r.contains(name)); grammar_json.conflicts.retain(|r| !r.contains(name));
grammar_json.supertypes.retain(|r| r != name); grammar_json.supertypes.retain(|r| r != name);