diff --git a/src/compiler/build_tables/rule_transitions.cc b/src/compiler/build_tables/rule_transitions.cc index 8ba6a198..719f1fe4 100644 --- a/src/compiler/build_tables/rule_transitions.cc +++ b/src/compiler/build_tables/rule_transitions.cc @@ -39,12 +39,6 @@ namespace tree_sitter { }); } - template - void transform_transitions(map *transitions, std::function fn) { - for (auto &pair : *transitions) - pair.second = fn(pair.second); - } - template class RuleTransitions : public rules::RuleFn> { map apply_to_atom(const rules::Rule *rule) { @@ -72,28 +66,24 @@ namespace tree_sitter { map apply_to(const rules::Seq *rule) { auto result = this->apply(rule->left); - transform_transitions(&result, [&](const rule_ptr &left_rule) { - return rules::Seq::Build({ left_rule, rule->right }); - }); - if (rule_can_be_blank(rule->left)) { + for (auto &pair : result) + pair.second = rules::Seq::Build({ pair.second, rule->right }); + if (rule_can_be_blank(rule->left)) merge_transitions(&result, this->apply(rule->right)); - } return result; } map apply_to(const rules::Repeat *rule) { auto result = this->apply(rule->content); - transform_transitions(&result, [&](const rule_ptr &value) { - return rules::Seq::Build({ value, rule->copy() }); - }); + for (auto &pair : result) + pair.second = rules::Seq::Build({ pair.second, rule->copy() }); return result; } map apply_to(const rules::Metadata *rule) { auto result = this->apply(rule->rule); - transform_transitions(&result, [&](const rule_ptr &to_rule) { - return make_shared(to_rule, rule->value); - }); + for (auto &pair : result) + pair.second = make_shared(pair.second, rule->value); return result; } };