diff --git a/src/builtin_eval.cpp b/src/builtin_eval.cpp index 7a3acc9b9..589525dad 100644 --- a/src/builtin_eval.cpp +++ b/src/builtin_eval.cpp @@ -27,7 +27,7 @@ int builtin_eval(parser_t &parser, io_streams_t &streams, wchar_t **argv) { const auto cached_exec_count = parser.libdata().exec_count; int status = STATUS_CMD_OK; if (argc > 1) { - if (parser.eval(std::move(new_cmd), *streams.io_chain) != eval_result_t::ok) { + if (parser.eval(new_cmd, *streams.io_chain) != eval_result_t::ok) { status = STATUS_CMD_ERROR; } else if (cached_exec_count == parser.libdata().exec_count) { // Issue #5692, in particular, to catch `eval ""`, `eval "begin; end;"`, etc. diff --git a/src/builtin_status.cpp b/src/builtin_status.cpp index 34765bb21..012a18f54 100644 --- a/src/builtin_status.cpp +++ b/src/builtin_status.cpp @@ -65,7 +65,7 @@ const enum_map status_enum_map[] = { #define status_enum_map_len (sizeof status_enum_map / sizeof *status_enum_map) #define CHECK_FOR_UNEXPECTED_STATUS_ARGS(status_cmd) \ - if (args.size() != 0) { \ + if (!args.empty()) { \ const wchar_t *subcmd_str = enum_to_str(status_cmd, status_enum_map); \ if (!subcmd_str) subcmd_str = L"default"; \ streams.err.append_format(BUILTIN_ERR_ARG_COUNT2, cmd, subcmd_str, 0, args.size()); \ diff --git a/src/builtin_string.cpp b/src/builtin_string.cpp index 7dbf58e58..36a1b7042 100644 --- a/src/builtin_string.cpp +++ b/src/builtin_string.cpp @@ -615,7 +615,7 @@ class string_matcher_t { public: string_matcher_t(options_t opts_, io_streams_t &streams_) - : opts(std::move(opts_)), streams(streams_), total_matched(0) {} + : opts(opts_), streams(streams_), total_matched(0) {} virtual ~string_matcher_t() = default; virtual bool report_matches(const wcstring &arg) = 0; @@ -888,7 +888,7 @@ class string_replacer_t { public: string_replacer_t(const wchar_t *argv0_, options_t opts_, io_streams_t &streams_) - : argv0(argv0_), opts(std::move(opts_)), total_replaced(0), streams(streams_) {} + : argv0(argv0_), opts(opts_), total_replaced(0), streams(streams_) {} virtual ~string_replacer_t() = default; int replace_count() const { return total_replaced; } @@ -901,10 +901,10 @@ class literal_replacer_t : public string_replacer_t { size_t patlen; public: - literal_replacer_t(const wchar_t *argv0, const wcstring &pattern_, const wchar_t *replacement_, + literal_replacer_t(const wchar_t *argv0, wcstring pattern_, const wchar_t *replacement_, const options_t &opts, io_streams_t &streams) : string_replacer_t(argv0, opts, streams), - pattern(pattern_), + pattern(std::move(pattern_)), replacement(replacement_), patlen(pattern.length()) {} diff --git a/src/builtin_test.cpp b/src/builtin_test.cpp index a3c9b640d..2814a3046 100644 --- a/src/builtin_test.cpp +++ b/src/builtin_test.cpp @@ -217,7 +217,7 @@ struct range_t { /// Base class for expressions. class expression { protected: - expression(token_t what, range_t where) : token(what), range(std::move(where)) {} + expression(token_t what, range_t where) : token(what), range(where) {} public: const token_t token; @@ -266,7 +266,7 @@ class combining_expression : public expression { const std::vector combiners; combining_expression(token_t tok, range_t where, std::vector> exprs, - const std::vector &combs) + std::vector combs) : expression(tok, where), subjects(std::move(exprs)), combiners(std::move(combs)) { // We should have one more subject than combiner. assert(subjects.size() == combiners.size() + 1); @@ -311,7 +311,7 @@ unique_ptr test_parser::parse_unary_expression(unsigned int start, u token_t tok = token_for_string(arg(start))->tok; if (tok == test_bang) { unique_ptr subject(parse_unary_expression(start + 1, end)); - if (subject.get()) { + if (subject) { return make_unique(tok, range_t(start, subject->range.end), move(subject)); } @@ -496,7 +496,7 @@ unique_ptr test_parser::parse_4_arg_expression(unsigned int start, u token_t first_token = token_for_string(arg(start))->tok; if (first_token == test_bang) { unique_ptr subject(parse_3_arg_expression(start + 1, end)); - if (subject.get()) { + if (subject) { result = make_unique(first_token, range_t(start, subject->range.end), move(subject)); } diff --git a/src/common.cpp b/src/common.cpp index 96873f17a..6f36c6dff 100644 --- a/src/common.cpp +++ b/src/common.cpp @@ -108,7 +108,7 @@ static owning_lock s_termsize{k_invalid_termsize}; static relaxed_atomic_bool_t s_termsize_valid{false}; static char *wcs2str_internal(const wchar_t *in, char *out); -static void debug_shared(const wchar_t msg_level, const wcstring &msg); +static void debug_shared(wchar_t msg_level, const wcstring &msg); #if defined(OS_IS_CYGWIN) || defined(WSL) // MS Windows tty devices do not currently have either a read or write timestamp. Those @@ -205,8 +205,7 @@ bool is_windows_subsystem_for_linux() { #ifdef HAVE_BACKTRACE_SYMBOLS // This function produces a stack backtrace with demangled function & method names. It is based on // https://gist.github.com/fmela/591333 but adapted to the style of the fish project. -[[gnu::noinline]] static const wcstring_list_t demangled_backtrace(int max_frames, - int skip_levels) { +[[gnu::noinline]] static wcstring_list_t demangled_backtrace(int max_frames, int skip_levels) { void *callstack[128]; const int n_max_frames = sizeof(callstack) / sizeof(callstack[0]); int n_frames = backtrace(callstack, n_max_frames); diff --git a/src/complete.cpp b/src/complete.cpp index 691c470ba..bba9adb7c 100644 --- a/src/complete.cpp +++ b/src/complete.cpp @@ -104,7 +104,7 @@ typedef struct complete_entry_opt { // Completion flags. complete_flags_t flags; - const wcstring localized_desc() const { return C_(desc); } + wcstring localized_desc() const { return C_(desc); } size_t expected_dash_count() const { switch (this->type) { @@ -209,7 +209,7 @@ completion_t::completion_t(wcstring comp, wcstring desc, string_fuzzy_match_t ma complete_flags_t flags_val) : completion(std::move(comp)), description(std::move(desc)), - match(std::move(mat)), + match(mat), flags(resolve_auto_space(completion, flags_val)) {} completion_t::completion_t(const completion_t &) = default; @@ -389,9 +389,9 @@ class completer_t { const std::vector &args); public: - completer_t(const environment_t &vars, const std::shared_ptr &parser, wcstring c, + completer_t(const environment_t &vars, std::shared_ptr parser, wcstring c, completion_request_flags_t f) - : vars(vars), parser(parser), cmd(std::move(c)), flags(f) {} + : vars(vars), parser(std::move(parser)), cmd(std::move(c)), flags(f) {} void perform(); @@ -1649,16 +1649,16 @@ void complete(const wcstring &cmd_with_subcmds, std::vector *out_c /// Print the short switch \c opt, and the argument \c arg to the specified /// wcstring, but only if \c argument isn't an empty string. -static void append_switch(wcstring &out, wchar_t opt, const wcstring arg) { +static void append_switch(wcstring &out, wchar_t opt, const wcstring &arg) { if (arg.empty()) return; append_format(out, L" -%lc %ls", opt, escape_string(arg, ESCAPE_ALL).c_str()); } -static void append_switch(wcstring &out, const wcstring opt, const wcstring arg) { +static void append_switch(wcstring &out, const wcstring &opt, const wcstring &arg) { if (arg.empty()) return; append_format(out, L" --%ls %ls", opt.c_str(), escape_string(arg, ESCAPE_ALL).c_str()); } static void append_switch(wcstring &out, wchar_t opt) { append_format(out, L" -%lc", opt); } -static void append_switch(wcstring &out, const wcstring opt) { +static void append_switch(wcstring &out, const wcstring &opt) { append_format(out, L" --%ls", opt.c_str()); } diff --git a/src/env.cpp b/src/env.cpp index 831c42c4a..7ed5426b2 100644 --- a/src/env.cpp +++ b/src/env.cpp @@ -848,7 +848,7 @@ class env_stack_impl_t final : public env_scoped_impl_t { return make_unique(std::move(local), s_global_node); } - virtual ~env_stack_impl_t() = default; + ~env_stack_impl_t() override = default; private: /// The scopes of caller functions, which are currently shadowed. @@ -878,7 +878,7 @@ class env_stack_impl_t final : public env_scoped_impl_t { /// Remove a variable from the chain \p node. /// \return true if the variable was found and removed. - bool remove_from_chain(env_node_ref_t node, const wcstring &key) const { + bool remove_from_chain(const env_node_ref_t &node, const wcstring &key) const { for (auto cursor = node; cursor; cursor = cursor->next) { auto iter = cursor->env.find(key); if (iter != cursor->env.end()) { @@ -901,7 +901,7 @@ class env_stack_impl_t final : public env_scoped_impl_t { void set_universal(const wcstring &key, wcstring_list_t val, const query_t &query); /// Set a variable in a given node \p node. - void set_in_node(env_node_ref_t node, const wcstring &key, wcstring_list_t &&val, + void set_in_node(const env_node_ref_t &node, const wcstring &key, wcstring_list_t &&val, const var_flags_t &flags); // Implement the default behavior of 'set' by finding the node for an unspecified scope. @@ -970,8 +970,8 @@ static wcstring_list_t colon_split(const wcstring_list_t &val) { return split_val; } -void env_stack_impl_t::set_in_node(env_node_ref_t node, const wcstring &key, wcstring_list_t &&val, - const var_flags_t &flags) { +void env_stack_impl_t::set_in_node(const env_node_ref_t &node, const wcstring &key, + wcstring_list_t &&val, const var_flags_t &flags) { env_var_t &var = node->env[key]; // Use an explicit exports, or inherit from the existing variable. diff --git a/src/env_universal_common.cpp b/src/env_universal_common.cpp index 2f6b23d21..8e71c301a 100644 --- a/src/env_universal_common.cpp +++ b/src/env_universal_common.cpp @@ -277,9 +277,9 @@ void env_universal_t::set_internal(const wcstring &key, const env_var_t &var) { } } -void env_universal_t::set(const wcstring &key, env_var_t var) { +void env_universal_t::set(const wcstring &key, const env_var_t &var) { scoped_lock locker(lock); - this->set_internal(key, std::move(var)); + this->set_internal(key, var); } bool env_universal_t::remove_internal(const wcstring &key) { diff --git a/src/env_universal_common.h b/src/env_universal_common.h index 12d12d3c2..ae4bd3691 100644 --- a/src/env_universal_common.h +++ b/src/env_universal_common.h @@ -103,7 +103,7 @@ class env_universal_t { maybe_t get_flags(const wcstring &name) const; // Sets a variable. - void set(const wcstring &key, env_var_t var); + void set(const wcstring &key, const env_var_t &var); // Removes a variable. Returns true if it was found, false if not. bool remove(const wcstring &key); diff --git a/src/exec.cpp b/src/exec.cpp index 5c6f36f68..d486517fb 100644 --- a/src/exec.cpp +++ b/src/exec.cpp @@ -241,7 +241,7 @@ static void on_process_created(const std::shared_ptr &j, pid_t child_pid) /// (stdout), and there is a dup2 3->1, then we need to write to fd 3. Then exit the internal /// process. static bool run_internal_process(process_t *p, std::string outdata, std::string errdata, - io_chain_t ios) { + const io_chain_t &ios) { p->check_generations_before_launch(); // We want both the dup2s and the io_chain_ts to be kept alive by the background thread, because @@ -748,8 +748,8 @@ static proc_performer_t get_performer_for_process(process_t *p, const job_t *job /// \p conflicts contains the list of fds which pipes should avoid. /// \p allow_buffering if true, permit buffering the output. /// \return true on success, false on error. -static bool exec_block_or_func_process(parser_t &parser, std::shared_ptr j, process_t *p, - const fd_set_t &conflicts, io_chain_t io_chain, +static bool exec_block_or_func_process(parser_t &parser, const std::shared_ptr &j, + process_t *p, const fd_set_t &conflicts, io_chain_t io_chain, bool allow_buffering) { // Create an output buffer if we're piping to another process. shared_ptr block_output_bufferfill{}; @@ -807,7 +807,7 @@ static bool exec_block_or_func_process(parser_t &parser, std::shared_ptr /// \p deferred_pipes represents the pipes from our deferred process; if set ensure they get closed /// in any child. If \p is_deferred_run is true, then this is a deferred run; this affects how /// certain buffering works. \returns true on success, false on exec error. -static bool exec_process_in_job(parser_t &parser, process_t *p, std::shared_ptr j, +static bool exec_process_in_job(parser_t &parser, process_t *p, const std::shared_ptr &j, const io_chain_t &block_io, autoclose_pipes_t pipes, const fd_set_t &conflicts, const autoclose_pipes_t &deferred_pipes, size_t stdout_read_limit, bool is_deferred_run = false) { @@ -995,7 +995,7 @@ static bool should_claim_process_group_for_job(const shared_ptr &j) { DIE("unreachable"); } -bool exec_job(parser_t &parser, shared_ptr j, const job_lineage_t &lineage) { +bool exec_job(parser_t &parser, const shared_ptr &j, const job_lineage_t &lineage) { assert(j && "null job_t passed to exec_job!"); // Set to true if something goes wrong while executing the job, in which case the cleanup diff --git a/src/exec.h b/src/exec.h index 37fee0b25..af3f1481b 100644 --- a/src/exec.h +++ b/src/exec.h @@ -15,7 +15,7 @@ class job_t; struct job_lineage_t; class parser_t; -bool exec_job(parser_t &parser, std::shared_ptr j, const job_lineage_t &lineage); +bool exec_job(parser_t &parser, const std::shared_ptr &j, const job_lineage_t &lineage); /// Evaluate the expression cmd in a subshell, add the outputs into the list l. On return, the /// status flag as returned bu \c proc_gfet_last_status will not be changed. diff --git a/src/expand.cpp b/src/expand.cpp index a13b02da1..d46b28fad 100644 --- a/src/expand.cpp +++ b/src/expand.cpp @@ -873,9 +873,9 @@ class expander_t { expand_result_t stage_home_and_self(wcstring input, std::vector *out); expand_result_t stage_wildcards(wcstring path_to_expand, std::vector *out); - expander_t(const environment_t &vars, const std::shared_ptr &parser, - expand_flags_t flags, parse_error_list_t *errors) - : vars(vars), parser(parser), flags(flags), errors(errors) {} + expander_t(const environment_t &vars, std::shared_ptr parser, expand_flags_t flags, + parse_error_list_t *errors) + : vars(vars), parser(std::move(parser)), flags(flags), errors(errors) {} public: static expand_result_t expand_string(wcstring input, std::vector *out_completions, diff --git a/src/function.cpp b/src/function.cpp index f659239e0..283d79d89 100644 --- a/src/function.cpp +++ b/src/function.cpp @@ -166,7 +166,8 @@ void function_add(wcstring name, wcstring description, function_properties_ref_t // Create and store a new function. auto ins = funcset->funcs.emplace( - std::move(name), function_info_t(props, std::move(description), filename, is_autoload)); + std::move(name), + function_info_t(std::move(props), std::move(description), filename, is_autoload)); assert(ins.second && "Function should not already be present in the table"); (void)ins; } diff --git a/src/input.cpp b/src/input.cpp index 6aec246b3..e2600656d 100644 --- a/src/input.cpp +++ b/src/input.cpp @@ -17,6 +17,7 @@ #include #include #include +#include #include #include "common.h" @@ -427,9 +428,9 @@ bool inputter_t::mapping_is_match(const input_mapping_t &m) { return true; } -void inputter_t::queue_ch(char_event_t ch) { event_queue_.push_back(ch); } +void inputter_t::queue_ch(const char_event_t &ch) { event_queue_.push_back(std::move(ch)); } -void inputter_t::push_front(char_event_t ch) { event_queue_.push_front(ch); } +void inputter_t::push_front(const char_event_t &ch) { event_queue_.push_front(std::move(ch)); } /// \return the first mapping that matches, walking first over the user's mapping list, then the /// preset list. \return null if nothing matches. diff --git a/src/input.h b/src/input.h index 63e4e4533..45b714a12 100644 --- a/src/input.h +++ b/src/input.h @@ -57,10 +57,10 @@ class inputter_t { /// Enqueue a char event to the queue of unread characters that input_readch will return before /// actually reading from fd 0. - void queue_ch(char_event_t ch); + void queue_ch(const char_event_t &ch); /// Enqueue a char event to the front of the queue; this will be the next event returned. - void push_front(char_event_t ch); + void push_front(const char_event_t &ch); /// Sets the return status of the most recently executed input function. void function_set_status(bool status) { function_status_ = status; } diff --git a/src/input_common.cpp b/src/input_common.cpp index a333a5627..d877257bf 100644 --- a/src/input_common.cpp +++ b/src/input_common.cpp @@ -225,6 +225,6 @@ char_event_t input_event_queue_t::readch_timed(bool dequeue_timeouts) { return result; } -void input_event_queue_t::push_back(char_event_t ch) { queue_.push_back(ch); } +void input_event_queue_t::push_back(const char_event_t& ch) { queue_.push_back(ch); } -void input_event_queue_t::push_front(char_event_t ch) { queue_.push_front(ch); } +void input_event_queue_t::push_front(const char_event_t& ch) { queue_.push_front(ch); } diff --git a/src/input_common.h b/src/input_common.h index f9182fd33..2c5786717 100644 --- a/src/input_common.h +++ b/src/input_common.h @@ -186,11 +186,11 @@ class input_event_queue_t { /// Enqueue a character or a readline function to the queue of unread characters that /// readch will return before actually reading from fd 0. - void push_back(char_event_t ch); + void push_back(const char_event_t& ch); /// Add a character or a readline function to the front of the queue of unread characters. This /// will be the next character returned by readch. - void push_front(char_event_t ch); + void push_front(const char_event_t& ch); }; #endif diff --git a/src/io.cpp b/src/io.cpp index 9fa759f0d..38c088f67 100644 --- a/src/io.cpp +++ b/src/io.cpp @@ -278,7 +278,7 @@ void io_chain_t::print() const { std::fwprintf(stderr, L"Chain %p (%ld items):\n", this, (long)this->size()); for (size_t i = 0; i < this->size(); i++) { const auto &io = this->at(i); - if (io.get() == nullptr) { + if (io == nullptr) { std::fwprintf(stderr, L"\t(null)\n"); } else { std::fwprintf(stderr, L"\t%lu: fd:%d, ", (unsigned long)i, io->fd); diff --git a/src/parse_execution.cpp b/src/parse_execution.cpp index 8654b6bd1..d2e4b294c 100644 --- a/src/parse_execution.cpp +++ b/src/parse_execution.cpp @@ -1049,7 +1049,7 @@ eval_result_t parse_execution_context_t::apply_variable_assignments( vals.emplace_back(std::move(completion.completion)); } if (proc) proc->variable_assignments.push_back({variable_name, vals}); - parser->vars().set(std::move(variable_name), ENV_LOCAL | ENV_EXPORT, std::move(vals)); + parser->vars().set(variable_name, ENV_LOCAL | ENV_EXPORT, std::move(vals)); } return eval_result_t::ok; } @@ -1410,13 +1410,13 @@ eval_result_t parse_execution_context_t::run_job_list(tnode_t job_list, result = this->run_job_conjunction(job_conj, associated_block); } if (timer_started) { - auto t1 = std::move(active_timers.back()); + auto t1 = active_timers.back(); active_timers.pop_back(); auto t2 = timer_snapshot_t::take(); // Well, this is awkward. By defining `time` as a decorator and not a built-in, there's // no associated stream for its output! - auto output = timer_snapshot_t::print_delta(std::move(t1), std::move(t2), true); + auto output = timer_snapshot_t::print_delta(t1, t2, true); std::fwprintf(stderr, L"%S\n", output.c_str()); } } diff --git a/src/parse_execution.h b/src/parse_execution.h index b9c7a4d90..52a8ff2f1 100644 --- a/src/parse_execution.h +++ b/src/parse_execution.h @@ -123,7 +123,7 @@ class parse_execution_context_t { // Determines the list of redirections for a node. Returns none() on failure, for example, an // invalid fd. bool determine_redirections(tnode_t node, - redirection_spec_list_t *out_redirs); + redirection_spec_list_t *out_redirections); eval_result_t run_1_job(tnode_t job, const block_t *associated_block); eval_result_t run_job_conjunction(tnode_t job_expr, diff --git a/src/parser.cpp b/src/parser.cpp index e901b61d6..e0ee0bb1b 100644 --- a/src/parser.cpp +++ b/src/parser.cpp @@ -110,7 +110,7 @@ void parser_t::skip_all_blocks() { // Given a new-allocated block, push it onto our block list, acquiring ownership. block_t *parser_t::push_block(block_t &&block) { - block_t new_current{std::move(block)}; + block_t new_current{block}; const enum block_type_t type = new_current.type(); new_current.src_lineno = parser_t::get_lineno(); @@ -147,7 +147,7 @@ void parser_t::pop_block(const block_t *expected) { assert(!block_list.empty() && "empty block list"); // Acquire ownership out of the block list. - block_t old = std::move(block_list.front()); + block_t old = block_list.front(); block_list.pop_front(); if (old.wants_pop_env) vars().pop(); @@ -626,7 +626,7 @@ eval_result_t parser_t::eval(const wcstring &cmd, const io_chain_t &io, } } -eval_result_t parser_t::eval(parsed_source_ref_t ps, const io_chain_t &io, +eval_result_t parser_t::eval(const parsed_source_ref_t &ps, const io_chain_t &io, enum block_type_t block_type) { assert(block_type == block_type_t::top || block_type == block_type_t::subst); if (!ps->tree.empty()) { @@ -640,8 +640,8 @@ eval_result_t parser_t::eval(parsed_source_ref_t ps, const io_chain_t &io, } template -eval_result_t parser_t::eval_node(parsed_source_ref_t ps, tnode_t node, job_lineage_t lineage, - block_type_t block_type) { +eval_result_t parser_t::eval_node(const parsed_source_ref_t &ps, tnode_t node, + job_lineage_t lineage, block_type_t block_type) { static_assert( std::is_same::value || std::is_same::value, "Unexpected node type"); @@ -683,9 +683,9 @@ eval_result_t parser_t::eval_node(parsed_source_ref_t ps, tnode_t node, job_l } // Explicit instantiations. TODO: use overloads instead? -template eval_result_t parser_t::eval_node(parsed_source_ref_t, tnode_t, +template eval_result_t parser_t::eval_node(const parsed_source_ref_t &, tnode_t, job_lineage_t, block_type_t); -template eval_result_t parser_t::eval_node(parsed_source_ref_t, tnode_t, +template eval_result_t parser_t::eval_node(const parsed_source_ref_t &, tnode_t, job_lineage_t, block_type_t); void parser_t::get_backtrace(const wcstring &src, const parse_error_list_t &errors, diff --git a/src/parser.h b/src/parser.h index 6357643bf..599f93299 100644 --- a/src/parser.h +++ b/src/parser.h @@ -268,13 +268,13 @@ class parser_t : public std::enable_shared_from_this { /// Evaluate the parsed source ps. /// Because the source has been parsed, a syntax error is impossible. - eval_result_t eval(parsed_source_ref_t ps, const io_chain_t &io, + eval_result_t eval(const parsed_source_ref_t &ps, const io_chain_t &io, block_type_t block_type = block_type_t::top); /// Evaluates a node. /// The node type must be grammar::statement or grammar::job_list. template - eval_result_t eval_node(parsed_source_ref_t ps, tnode_t node, job_lineage_t lineage, + eval_result_t eval_node(const parsed_source_ref_t &ps, tnode_t node, job_lineage_t lineage, block_type_t block_type = block_type_t::top); /// Evaluate line as a list of parameters, i.e. tokenize it and perform parameter expansion and diff --git a/src/proc.cpp b/src/proc.cpp index 0a418936a..60d779afb 100644 --- a/src/proc.cpp +++ b/src/proc.cpp @@ -269,7 +269,7 @@ void process_t::check_generations_before_launch() { gens_ = topic_monitor_t::principal().current_generations(); } -job_t::job_t(job_id_t job_id, const properties_t &props, job_lineage_t lineage) +job_t::job_t(job_id_t job_id, const properties_t &props, const job_lineage_t &lineage) : properties(props), job_id(job_id), root_constructed(lineage.root_constructed ? lineage.root_constructed : this->constructed) {} diff --git a/src/proc.h b/src/proc.h index 5042f35c7..63772b434 100644 --- a/src/proc.h +++ b/src/proc.h @@ -320,7 +320,7 @@ class job_t { void operator=(const job_t &) = delete; public: - job_t(job_id_t job_id, const properties_t &props, job_lineage_t lineage); + job_t(job_id_t job_id, const properties_t &props, const job_lineage_t &lineage); ~job_t(); /// Returns the command as a wchar_t *. */ diff --git a/src/reader.cpp b/src/reader.cpp index a20163a99..eb406f35e 100644 --- a/src/reader.cpp +++ b/src/reader.cpp @@ -1299,7 +1299,7 @@ static std::function get_autosuggestion_performer history_search_t searcher(*history, search_string, history_search_type_t::prefix); while (!reader_test_should_cancel() && searcher.go_backwards()) { - history_item_t item = searcher.current_item(); + const history_item_t &item = searcher.current_item(); // Skip items with newlines because they make terrible autosuggestions. if (item.str().find(L'\n') != wcstring::npos) continue; @@ -2754,7 +2754,7 @@ void reader_data_t::handle_readline_command(readline_cmd_t c, readline_loop_stat if (abbreviation_expanded) { // It's our reponsibility to rehighlight and repaint. But everything we do // below triggers a repaint. - command_test_result = test_func(parser(), el->text.c_str()); + command_test_result = test_func(parser(), el->text); // If the command is OK, then we're going to execute it. We still want to do // syntax highlighting, but a synchronous variant that performs no I/O, so diff --git a/src/screen.cpp b/src/screen.cpp index ed8668fa7..bda1996e9 100644 --- a/src/screen.cpp +++ b/src/screen.cpp @@ -278,7 +278,7 @@ maybe_t layout_cache_t::find_prompt_layout(const wcstring &inpu void layout_cache_t::add_prompt_layout(wcstring input, prompt_layout_t layout) { assert(!find_prompt_layout(input) && "Should not have a prompt layout for this input"); - prompt_cache_.emplace_front(std::move(input), std::move(layout)); + prompt_cache_.emplace_front(std::move(input), layout); if (prompt_cache_.size() > prompt_cache_max_size) { prompt_cache_.pop_back(); } diff --git a/src/tokenizer.cpp b/src/tokenizer.cpp index 450cbc6e9..872518be7 100644 --- a/src/tokenizer.cpp +++ b/src/tokenizer.cpp @@ -136,7 +136,7 @@ enum { curly_braces = 1 << 2, char_escape = 1 << 3, }; -} +} // namespace tok_modes using tok_mode_t = uint32_t; /// Read the next token as a string. diff --git a/src/wutil.cpp b/src/wutil.cpp index 9f21f3131..ea7bdf694 100644 --- a/src/wutil.cpp +++ b/src/wutil.cpp @@ -130,7 +130,7 @@ bool wreaddir_for_dirs(DIR *dir, wcstring *out_name) { return result != nullptr; } -const wcstring wgetcwd() { +wcstring wgetcwd() { char cwd[PATH_MAX]; char *res = getcwd(cwd, sizeof(cwd)); if (res) { diff --git a/src/wutil.h b/src/wutil.h index 8a3b74cd4..636eff347 100644 --- a/src/wutil.h +++ b/src/wutil.h @@ -71,7 +71,7 @@ void safe_perror(const char *message); const char *safe_strerror(int err); /// Wide character version of getcwd(). -const wcstring wgetcwd(); +wcstring wgetcwd(); /// Wide character version of realpath function. /// \returns the canonicalized path, or none if the path is invalid.