From 5b2b407a29bb092e800777e3a33d786bb9e77856 Mon Sep 17 00:00:00 2001 From: Oscar Franco Date: Sun, 1 Dec 2024 11:10:45 +0100 Subject: [PATCH] Use emplace back for utils --- cpp/utils.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/cpp/utils.cpp b/cpp/utils.cpp index 97b0df9..d7a41e1 100644 --- a/cpp/utils.cpp +++ b/cpp/utils.cpp @@ -84,7 +84,7 @@ std::vector to_string_vec(jsi::Runtime &rt, jsi::Value const &xs) { std::vector res; for (int ii = 0; ii < values.length(rt); ii++) { std::string value = values.getValueAtIndex(rt, ii).asString(rt).utf8(rt); - res.push_back(value); + res.emplace_back(value); } return res; } @@ -94,7 +94,7 @@ std::vector to_int_vec(jsi::Runtime &rt, jsi::Value const &xs) { std::vector res; for (int ii = 0; ii < values.length(rt); ii++) { int value = static_cast(values.getValueAtIndex(rt, ii).asNumber()); - res.push_back(value); + res.emplace_back(value); } return res; } @@ -110,7 +110,7 @@ std::vector to_variant_vec(jsi::Runtime &rt, jsi::Value const &xs) { for (int ii = 0; ii < values.length(rt); ii++) { jsi::Value value = values.getValueAtIndex(rt, ii); - res.push_back(toVariant(rt, value)); + res.emplace_back(toVariant(rt, value)); } return res; @@ -235,12 +235,12 @@ void to_batch_arguments(jsi::Runtime &rt, jsi::Array const &batchParams, const jsi::Value &p = batchUpdateParams.getValueAtIndex(rt, x); auto params = std::make_shared>(to_variant_vec(rt, p)); - commands->push_back({query, params}); + commands->emplace_back(query, params); } } else { auto params = std::make_shared>( to_variant_vec(rt, commandParams)); - commands->push_back({query, params}); + commands->emplace_back(query, params); } } } @@ -304,7 +304,7 @@ std::vector parse_string_list(const std::string &str) { std::istringstream stream(str); std::string token; while (std::getline(stream, token, ',')) { - result.push_back(token); + result.emplace_back(token); } return result; }