From 194fa4a548bcc93a37047ec53a3c76f49f90f109 Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Thu, 2 Apr 2020 17:07:36 -0700 Subject: [PATCH] [clang-tidy] performance Found with performance* Signed-off-by: Rosen Penev --- src/autoload.cpp | 2 +- src/expand.cpp | 2 +- src/input.cpp | 4 ++-- src/input_common.cpp | 2 +- src/reader.cpp | 6 +++--- src/timer.cpp | 4 ++-- src/wildcard.cpp | 4 ++-- 7 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/autoload.cpp b/src/autoload.cpp index 11c51c92e..7661c15f2 100644 --- a/src/autoload.cpp +++ b/src/autoload.cpp @@ -141,7 +141,7 @@ maybe_t autoload_file_cache_t::check(const wcstring &cmd, b autoload_t::autoload_t(wcstring env_var_name) : env_var_name_(std::move(env_var_name)), cache_(make_unique()) {} -autoload_t::autoload_t(autoload_t &&) = default; +autoload_t::autoload_t(autoload_t &&) noexcept = default; autoload_t::~autoload_t() = default; void autoload_t::invalidate_cache() { diff --git a/src/expand.cpp b/src/expand.cpp index 5f17eb7f7..396745476 100644 --- a/src/expand.cpp +++ b/src/expand.cpp @@ -923,7 +923,7 @@ expand_result_t expander_t::stage_variables(wcstring input, completion_list_t *o // We accept incomplete strings here, since complete uses expand_string to expand incomplete // strings from the commandline. wcstring next; - unescape_string(std::move(input), &next, UNESCAPE_SPECIAL | UNESCAPE_INCOMPLETE); + unescape_string(input, &next, UNESCAPE_SPECIAL | UNESCAPE_INCOMPLETE); if (flags & expand_flag::skip_variables) { for (auto &i : next) { diff --git a/src/input.cpp b/src/input.cpp index 53da3e7af..72f84a509 100644 --- a/src/input.cpp +++ b/src/input.cpp @@ -431,9 +431,9 @@ bool inputter_t::mapping_is_match(const input_mapping_t &m) { return true; } -void inputter_t::queue_ch(const char_event_t &ch) { event_queue_.push_back(std::move(ch)); } +void inputter_t::queue_ch(const char_event_t &ch) { event_queue_.push_back(ch); } -void inputter_t::push_front(const char_event_t &ch) { event_queue_.push_front(std::move(ch)); } +void inputter_t::push_front(const char_event_t &ch) { event_queue_.push_front(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_common.cpp b/src/input_common.cpp index c5604bbfd..a7897008f 100644 --- a/src/input_common.cpp +++ b/src/input_common.cpp @@ -39,7 +39,7 @@ static int wait_on_escape_ms = WAIT_ON_ESCAPE_DEFAULT; /// Callback function for handling interrupts on reading. static interrupt_func_t interrupt_handler; -void input_common_init(interrupt_func_t func) { interrupt_handler = std::move(func); } +void input_common_init(interrupt_func_t func) { interrupt_handler = func; } /// Internal function used by input_common_readch to read one byte from fd 0. This function should /// only be called by input_common_readch(). diff --git a/src/reader.cpp b/src/reader.cpp index 67014577d..172d3a7a2 100644 --- a/src/reader.cpp +++ b/src/reader.cpp @@ -240,7 +240,7 @@ bool editable_line_t::undo() { edit_t inverse = edit_t(edit.offset, edit.replacement.size(), L""); inverse.replacement = edit.old; size_t old_position = edit.cursor_position_before_edit; - apply_edit(&text_, std::move(inverse)); + apply_edit(&text_, inverse); set_position(old_position); undo_history.may_coalesce = false; return true; @@ -2330,10 +2330,10 @@ void reader_set_expand_abbreviations(bool flag) { current_data()->expand_abbrevi void reader_set_complete_ok(bool flag) { current_data()->complete_ok = flag; } void reader_set_highlight_function(highlight_function_t func) { - current_data()->highlight_func = std::move(func); + current_data()->highlight_func = func; } -void reader_set_test_function(test_function_t f) { current_data()->test_func = std::move(f); } +void reader_set_test_function(test_function_t f) { current_data()->test_func = f; } void reader_set_exit_on_interrupt(bool i) { current_data()->exit_on_interrupt = i; } diff --git a/src/timer.cpp b/src/timer.cpp index 8ebae52dc..248b9144b 100644 --- a/src/timer.cpp +++ b/src/timer.cpp @@ -201,13 +201,13 @@ wcstring timer_snapshot_t::print_delta(timer_snapshot_t t1, timer_snapshot_t t2, static std::vector active_timers; static void pop_timer() { - 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/wildcard.cpp b/src/wildcard.cpp index af397acb3..471d16348 100644 --- a/src/wildcard.cpp +++ b/src/wildcard.cpp @@ -166,7 +166,7 @@ static wcstring resolve_description(const wcstring &full_completion, wcstring *c size_t complete_sep_loc = completion->find(PROG_COMPLETE_SEP); if (complete_sep_loc != wcstring::npos) { // This completion has an embedded description, do not use the generic description. - const wcstring description = completion->substr(complete_sep_loc + 1); + wcstring description = completion->substr(complete_sep_loc + 1); completion->resize(complete_sep_loc); return description; } @@ -218,7 +218,7 @@ static bool wildcard_complete_internal(const wchar_t *str, const wchar_t *wc, // Maybe we have no more wildcards at all. This includes the empty string. if (next_wc_char_pos == wcstring::npos) { - string_fuzzy_match_t match = string_fuzzy_match_string(wc, str); + auto match = string_fuzzy_match_string(wc, str); // If we're allowing fuzzy match, any match is OK. Otherwise we require a prefix match. bool match_acceptable;