From 3633c51ad8aee79add7727457c998c42a1638f72 Mon Sep 17 00:00:00 2001 From: ridiculousfish Date: Sun, 28 Feb 2016 00:44:20 -0800 Subject: Re-use the parse tree generated during error detection for execution Prior to this fix, read_ni would use parse_util_detect_errors to lint the script to run, and then parser_t::eval() to execute it. Both functions would parse the script into a parse tree. This allows us to re-use the parse tree, improving perfomance. --- src/reader.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/reader.cpp') diff --git a/src/reader.cpp b/src/reader.cpp index 1b4f8d2d..3998e5a0 100644 --- a/src/reader.cpp +++ b/src/reader.cpp @@ -4258,9 +4258,10 @@ static int read_ni(int fd, const io_chain_t &io) } parse_error_list_t errors; - if (! parse_util_detect_errors(str, &errors, false /* do not accept incomplete */)) + parse_node_tree_t tree; + if (! parse_util_detect_errors(str, &errors, false /* do not accept incomplete */, &tree)) { - parser.eval(str, io, TOP); + parser.eval_acquiring_tree(str, io, TOP, moved_ref(tree)); } else { -- cgit v1.2.3