[clang-tidy] Add const to reference

Found with performance-unnecessary-copy-initialization
This commit is contained in:
Rosen Penev 2019-12-21 13:53:48 -08:00
parent 5d1ad8de91
commit b1349f44f6
No known key found for this signature in database
GPG key ID: 36D31CFA845F0E3B
9 changed files with 13 additions and 13 deletions

View file

@ -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.

View file

@ -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; }

View file

@ -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;

View file

@ -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;

View file

@ -279,7 +279,7 @@ 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) {
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) {

View file

@ -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;
}
@ -1409,13 +1409,13 @@ eval_result_t parse_execution_context_t::run_job_list(tnode_t<Type> 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());
}
}

View file

@ -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();

View file

@ -1299,7 +1299,7 @@ static std::function<autosuggestion_result_t(void)> 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;

View file

@ -278,7 +278,7 @@ maybe_t<prompt_layout_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();
}