From c984876e3ad5300893d0d96498a1286cc267309c Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Sat, 6 Aug 2016 21:22:44 -0700 Subject: [PATCH] Remove stack versions that are worse than the finished tree --- src/runtime/parser.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/runtime/parser.c b/src/runtime/parser.c index d11082c2..930abf61 100644 --- a/src/runtime/parser.c +++ b/src/runtime/parser.c @@ -367,6 +367,9 @@ static bool ts_parser__better_version_exists(TSParser *self, StackVersion version, unsigned my_error_depth, unsigned my_error_cost) { + if (self->finished_tree && self->finished_tree->error_size <= my_error_cost) + return true; + for (StackVersion i = 0, n = ts_stack_version_count(self->stack); i < n; i++) { if (i == version || ts_stack_is_halted(self->stack, i)) continue;