From ba91b3971540a6dd80b17ff4e8916d73cc02a001 Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Tue, 17 Aug 2021 02:20:28 -0700 Subject: [PATCH] replace push_back with emplate_back The latter forwards the arguments directly. Signed-off-by: Rosen Penev --- src/builtin_argparse.cpp | 2 +- src/builtin_string.cpp | 2 +- src/fish_tests.cpp | 10 +++++----- src/input.cpp | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/builtin_argparse.cpp b/src/builtin_argparse.cpp index 93cf4d433..5783f83fa 100644 --- a/src/builtin_argparse.cpp +++ b/src/builtin_argparse.cpp @@ -521,7 +521,7 @@ static int validate_and_store_implicit_int(parser_t &parser, const argparse_cmd_ // It's a valid integer so store it and return success. opt_spec->vals.clear(); - opt_spec->vals.push_back(wcstring(val)); + opt_spec->vals.emplace_back(val); opt_spec->num_seen++; w.nextchar = nullptr; return STATUS_CMD_OK; diff --git a/src/builtin_string.cpp b/src/builtin_string.cpp index 3913b37e2..1689825c3 100644 --- a/src/builtin_string.cpp +++ b/src/builtin_string.cpp @@ -1112,7 +1112,7 @@ class pcre2_matcher_t final : public string_matcher_t { // resulting array, and unfortunately fish doesn't support empty/null members so // we're going to have to use an empty string as the sentinel value. if (!value_found && all_flag_) { - vals.push_back(wcstring{}); + vals.emplace_back(); } } } diff --git a/src/fish_tests.cpp b/src/fish_tests.cpp index 331a5c2f8..a7fb61340 100644 --- a/src/fish_tests.cpp +++ b/src/fish_tests.cpp @@ -1991,7 +1991,7 @@ class test_lru_t : public lru_cache_t { std::vector evicted; - void entry_was_evicted(const wcstring &key, int val) { evicted.push_back({key, val}); } + void entry_was_evicted(const wcstring &key, int val) { evicted.emplace_back(key, val); } std::vector values() const { std::vector result; @@ -2020,12 +2020,12 @@ static void test_lru() { for (int i = 0; i < total_nodes; i++) { do_test(cache.size() == size_t(std::min(i, 16))); do_test(cache.values() == expected_values); - if (i < 4) expected_evicted.push_back({to_string(i), i}); + if (i < 4) expected_evicted.emplace_back(to_string(i), i); // Adding the node the first time should work, and subsequent times should fail. do_test(cache.insert(to_string(i), i)); do_test(!cache.insert(to_string(i), i + 1)); - expected_values.push_back({to_string(i), i}); + expected_values.emplace_back(to_string(i), i); while (expected_values.size() > test_lru_t::test_capacity) { expected_values.erase(expected_values.begin()); } @@ -2135,7 +2135,7 @@ static bool expand_test(const wchar_t *in, expand_flags_t flags, ...) { va_start(va, flags); while ((arg = va_arg(va, wchar_t *)) != NULL) { - expected.push_back(wcstring(arg)); + expected.emplace_back(arg); } va_end(va); @@ -5078,7 +5078,7 @@ static wcstring_list_t separate_by_format_specifiers(const wchar_t *format) { // Don't return empty strings. if (next_specifier > cursor) { - result.push_back(wcstring(cursor, next_specifier - cursor)); + result.emplace_back(cursor, next_specifier - cursor); } // Walk over the format specifier (if any). diff --git a/src/input.cpp b/src/input.cpp index b3e820cfb..fa43b8672 100644 --- a/src/input.cpp +++ b/src/input.cpp @@ -896,7 +896,7 @@ wcstring_list_t input_terminfo_get_names(bool skip_null) { if (skip_null && !m.seq) { continue; } - result.push_back(wcstring(m.name)); + result.emplace_back(m.name); } return result; }