mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-27 05:13:10 +00:00
parser: try to avoid some strings being copied
This commit is contained in:
parent
25ba16d4b6
commit
7a74198aa3
5 changed files with 5 additions and 7 deletions
|
@ -734,8 +734,6 @@ parse_execution_result_t parse_execution_context_t::expand_command(
|
|||
|
||||
// Get the unexpanded command string. We expect to always get it here.
|
||||
wcstring unexp_cmd = *command_for_plain_statement(statement, pstree->src);
|
||||
wcstring cmd;
|
||||
wcstring_list_t args;
|
||||
|
||||
// Expand the string to produce completions, and report errors.
|
||||
expand_error_t expand_err =
|
||||
|
@ -879,7 +877,7 @@ parse_execution_result_t parse_execution_context_t::populate_plain_process(
|
|||
proc->type = process_type;
|
||||
proc->set_argv(cmd_args);
|
||||
proc->set_io_chain(process_io_chain);
|
||||
proc->actual_cmd = path_to_external_command;
|
||||
proc->actual_cmd = std::move(path_to_external_command);
|
||||
return parse_execution_success;
|
||||
}
|
||||
|
||||
|
|
|
@ -1135,7 +1135,7 @@ const parse_node_t *parse_node_tree_t::get_child(const parse_node_t &parent, nod
|
|||
return result;
|
||||
}
|
||||
|
||||
parsed_source_ref_t parse_source(wcstring src, parse_tree_flags_t flags, parse_error_list_t *errors,
|
||||
parsed_source_ref_t parse_source(const wcstring &src, parse_tree_flags_t flags, parse_error_list_t *errors,
|
||||
parse_token_type_t goal) {
|
||||
parse_node_tree_t tree;
|
||||
if (!parse_tree_from_string(src, flags, &tree, errors, goal)) return {};
|
||||
|
|
|
@ -233,7 +233,7 @@ struct parsed_source_t {
|
|||
};
|
||||
/// Return a shared pointer to parsed_source_t, or null on failure.
|
||||
using parsed_source_ref_t = std::shared_ptr<const parsed_source_t>;
|
||||
parsed_source_ref_t parse_source(wcstring src, parse_tree_flags_t flags, parse_error_list_t *errors,
|
||||
parsed_source_ref_t parse_source(const wcstring &src, parse_tree_flags_t flags, parse_error_list_t *errors,
|
||||
parse_token_type_t goal = symbol_job_list);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -629,7 +629,7 @@ profile_item_t *parser_t::create_profile_item() {
|
|||
return result;
|
||||
}
|
||||
|
||||
int parser_t::eval(wcstring cmd, const io_chain_t &io, enum block_type_t block_type) {
|
||||
int parser_t::eval(const wcstring &cmd, const io_chain_t &io, enum block_type_t block_type) {
|
||||
// Parse the source into a tree, if we can.
|
||||
parse_error_list_t error_list;
|
||||
parsed_source_ref_t ps = parse_source(cmd, parse_flag_none, &error_list);
|
||||
|
|
|
@ -222,7 +222,7 @@ class parser_t : public std::enable_shared_from_this<parser_t> {
|
|||
/// \param block_type The type of block to push on the block stack
|
||||
///
|
||||
/// \return 0 on success, 1 on a parse error.
|
||||
int eval(wcstring cmd, const io_chain_t &io, enum block_type_t block_type);
|
||||
int eval(const wcstring &cmd, const io_chain_t &io, enum block_type_t block_type);
|
||||
|
||||
/// Evaluate the parsed source ps.
|
||||
void eval(parsed_source_ref_t ps, const io_chain_t &io, enum block_type_t block_type);
|
||||
|
|
Loading…
Reference in a new issue