From 39861d54c549619b15ee8913d59e6cf442f28cb6 Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Fri, 13 Mar 2020 13:45:41 -0700 Subject: [PATCH] [cppcheck] add some std::move Found with passedByValue Signed-off-by: Rosen Penev --- src/builtin_string.cpp | 4 ++-- src/enum_set.h | 2 +- src/event.h | 2 +- src/expand.cpp | 2 +- src/input_common.cpp | 2 +- src/reader.cpp | 4 ++-- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/builtin_string.cpp b/src/builtin_string.cpp index 3367befbc..35230a3b0 100644 --- a/src/builtin_string.cpp +++ b/src/builtin_string.cpp @@ -617,7 +617,7 @@ class string_matcher_t { public: string_matcher_t(options_t opts_, io_streams_t &streams_) - : opts(opts_), streams(streams_), total_matched(0) {} + : opts(std::move(opts_)), streams(streams_), total_matched(0) {} virtual ~string_matcher_t() = default; virtual bool report_matches(const wcstring &arg) = 0; @@ -879,7 +879,7 @@ class string_replacer_t { public: string_replacer_t(const wchar_t *argv0_, options_t opts_, io_streams_t &streams_) - : argv0(argv0_), opts(opts_), total_replaced(0), streams(streams_) {} + : argv0(argv0_), opts(std::move(opts_)), total_replaced(0), streams(streams_) {} virtual ~string_replacer_t() = default; int replace_count() const { return total_replaced; } diff --git a/src/enum_set.h b/src/enum_set.h index c0217479d..f0d37e146 100644 --- a/src/enum_set.h +++ b/src/enum_set.h @@ -27,7 +27,7 @@ class enum_set_t : private std::bitset()> { static size_t index_of(T t) { return static_cast(t); } explicit enum_set_t(unsigned long raw) : super(raw) {} - explicit enum_set_t(super sup) : super(sup) {} + explicit enum_set_t(super sup) : super(std::move(sup)) {} public: enum_set_t() = default; diff --git a/src/event.h b/src/event.h index d584358cf..9e8e57636 100644 --- a/src/event.h +++ b/src/event.h @@ -74,7 +74,7 @@ struct event_handler_t { explicit event_handler_t(event_type_t t) : desc(t) {} event_handler_t(event_description_t d, wcstring name) - : desc(d), function_name(std::move(name)) {} + : desc(std::move(d)), function_name(std::move(name)) {} }; using event_handler_list_t = std::vector>; diff --git a/src/expand.cpp b/src/expand.cpp index 396745476..5f17eb7f7 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(input, &next, UNESCAPE_SPECIAL | UNESCAPE_INCOMPLETE); + unescape_string(std::move(input), &next, UNESCAPE_SPECIAL | UNESCAPE_INCOMPLETE); if (flags & expand_flag::skip_variables) { for (auto &i : next) { diff --git a/src/input_common.cpp b/src/input_common.cpp index a7897008f..c5604bbfd 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 = func; } +void input_common_init(interrupt_func_t func) { interrupt_handler = std::move(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 7f6de3506..9f2939434 100644 --- a/src/reader.cpp +++ b/src/reader.cpp @@ -2324,10 +2324,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 = func; + current_data()->highlight_func = std::move(func); } -void reader_set_test_function(test_function_t f) { current_data()->test_func = f; } +void reader_set_test_function(test_function_t f) { current_data()->test_func = std::move(f); } void reader_set_exit_on_interrupt(bool i) { current_data()->exit_on_interrupt = i; }