Revert "parser: try to avoid some strings being copied"

This reverts commit 7a74198aa3.

Believe it or not this commit actually increased copying. When accepting
a value you know you're going to take ownership of, just accept it by
value; then temporaries can invoke the move ctor and blah blah blah.

We really need a lightweight refcounted pass-by-value string to make this
less error prone.
This commit is contained in:
ridiculousfish
2019-04-01 20:19:28 -07:00
parent ab92baf671
commit dd007c29f4
4 changed files with 4 additions and 4 deletions

View File

@@ -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(const wcstring &src, parse_tree_flags_t flags, parse_error_list_t *errors,
parsed_source_ref_t parse_source(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 {};

View File

@@ -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(const wcstring &src, parse_tree_flags_t flags, parse_error_list_t *errors,
parsed_source_ref_t parse_source(wcstring src, parse_tree_flags_t flags, parse_error_list_t *errors,
parse_token_type_t goal = symbol_job_list);
#endif

View File

@@ -618,7 +618,7 @@ profile_item_t *parser_t::create_profile_item() {
return result;
}
int parser_t::eval(const wcstring &cmd, const io_chain_t &io, enum block_type_t block_type) {
int parser_t::eval(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);

View File

@@ -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(const wcstring &cmd, const io_chain_t &io, enum block_type_t block_type);
int eval(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);