From 48c50d202b98636a42184a812e3f2d45d4eb6286 Mon Sep 17 00:00:00 2001 From: ridiculousfish Date: Sat, 14 Nov 2020 14:12:53 -0800 Subject: [PATCH] Save a string allocation in expand_arguments_from_nodes This function is called a lot; we can save a little bit of memory here. --- src/parse_execution.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/parse_execution.cpp b/src/parse_execution.cpp index 56f765cb7..289205910 100644 --- a/src/parse_execution.cpp +++ b/src/parse_execution.cpp @@ -930,13 +930,13 @@ end_execution_reason_t parse_execution_context_t::expand_arguments_from_nodes( completion_list_t arg_expanded; for (const ast::argument_t *arg_node : argument_nodes) { // Expect all arguments to have source. - assert(arg_node->has_source()); - const wcstring arg_str = get_source(*arg_node); + assert(arg_node->has_source() && "Argument should have source"); // Expand this string. parse_error_list_t errors; arg_expanded.clear(); - auto expand_ret = expand_string(arg_str, &arg_expanded, expand_flags_t{}, ctx, &errors); + auto expand_ret = + expand_string(get_source(*arg_node), &arg_expanded, expand_flags_t{}, ctx, &errors); parse_error_offset_source_start(&errors, arg_node->range.start); switch (expand_ret.result) { case expand_result_t::error: {