Skip to content

Commit

Permalink
Use emplace back for utils
Browse files Browse the repository at this point in the history
  • Loading branch information
ospfranco committed Dec 1, 2024
1 parent b8af8b6 commit 5b2b407
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions cpp/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ std::vector<std::string> to_string_vec(jsi::Runtime &rt, jsi::Value const &xs) {
std::vector<std::string> 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;
}
Expand All @@ -94,7 +94,7 @@ std::vector<int> to_int_vec(jsi::Runtime &rt, jsi::Value const &xs) {
std::vector<int> res;
for (int ii = 0; ii < values.length(rt); ii++) {
int value = static_cast<int>(values.getValueAtIndex(rt, ii).asNumber());
res.push_back(value);
res.emplace_back(value);
}
return res;
}
Expand All @@ -110,7 +110,7 @@ std::vector<JSVariant> 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;
Expand Down Expand Up @@ -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<std::vector<JSVariant>>(to_variant_vec(rt, p));
commands->push_back({query, params});
commands->emplace_back(query, params);
}
} else {
auto params = std::make_shared<std::vector<JSVariant>>(
to_variant_vec(rt, commandParams));
commands->push_back({query, params});
commands->emplace_back(query, params);
}
}
}
Expand Down Expand Up @@ -304,7 +304,7 @@ std::vector<std::string> 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;
}
Expand Down

0 comments on commit 5b2b407

Please sign in to comment.