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.
This commit is contained in:
ridiculousfish
2016-02-28 00:44:20 -08:00
parent e3970f9cbb
commit 3633c51ad8
3 changed files with 13 additions and 6 deletions

View File

@@ -1287,7 +1287,7 @@ parser_test_error_bits_t parse_util_detect_errors_in_argument(const parse_node_t
return err;
}
parser_test_error_bits_t parse_util_detect_errors(const wcstring &buff_src, parse_error_list_t *out_errors, bool allow_incomplete)
parser_test_error_bits_t parse_util_detect_errors(const wcstring &buff_src, parse_error_list_t *out_errors, bool allow_incomplete, parse_node_tree_t *out_tree)
{
parse_node_tree_t node_tree;
parse_error_list_t parse_errors;
@@ -1546,10 +1546,15 @@ parser_test_error_bits_t parse_util_detect_errors(const wcstring &buff_src, pars
if (has_unclosed_block || has_unclosed_quote)
res |= PARSER_TEST_INCOMPLETE;
if (out_errors)
if (out_errors != NULL)
{
out_errors->swap(parse_errors);
}
if (out_tree != NULL)
{
out_tree->swap(node_tree);
}
return res;