replace push_back with emplate_back

The latter forwards the arguments directly.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
This commit is contained in:
Rosen Penev 2021-08-17 02:20:28 -07:00 committed by Mahmoud Al-Qudsi
parent c055e3ae66
commit ba91b39715
4 changed files with 8 additions and 8 deletions

View file

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

View file

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

View file

@ -1991,7 +1991,7 @@ class test_lru_t : public lru_cache_t<test_lru_t, int> {
std::vector<value_type> 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<value_type> values() const {
std::vector<value_type> 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).

View file

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