Skip to content

Commit

Permalink
More optimizations
Browse files Browse the repository at this point in the history
  • Loading branch information
ospfranco committed Oct 3, 2024
1 parent c10764c commit 60ac1b8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion cpp/DBHostObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ void DBHostObject::create_jsi_functions() {
auto resolve = std::make_shared<jsi::Value>(rt, args[0]);
auto reject = std::make_shared<jsi::Value>(rt, args[1]);

auto task = [&rt, this, query, params = std::move(params), resolve,
auto task = [&rt, this, query = std::move(query), params = std::move(params), resolve,
reject, invoker = this->jsCallInvoker]() {
try {

Expand Down
11 changes: 5 additions & 6 deletions cpp/bridge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ BridgeResult opsqlite_execute_prepared_statement(
}

if (results != nullptr) {
results->push_back(row);
results->emplace_back(row);
}

break;
Expand All @@ -335,7 +335,7 @@ BridgeResult opsqlite_execute_prepared_statement(
metadata.fields.emplace_back("type",
type == nullptr ? "UNKNOWN" : type);

metadatas->push_back(metadata);
metadatas->emplace_back(metadata);
i++;
}
}
Expand Down Expand Up @@ -400,11 +400,9 @@ BridgeResult opsqlite_execute(std::string const &name, std::string const &query,
int status, current_column, column_count, column_type;
std::string column_name, column_declared_type;
std::vector<std::string> column_names;
column_names.reserve(20);
std::vector<std::vector<JSVariant>> rows;
rows.reserve(20);
std::vector<JSVariant> row;
row.reserve(10);

do {
const char *query_str =
Expand Down Expand Up @@ -432,6 +430,7 @@ BridgeResult opsqlite_execute(std::string const &name, std::string const &query,
}

column_count = sqlite3_column_count(statement);
column_names.reserve(column_count);
bool is_consuming_rows = true;
double double_value;
const char *string_value;
Expand All @@ -449,7 +448,7 @@ BridgeResult opsqlite_execute(std::string const &name, std::string const &query,
case SQLITE_ROW:
current_column = 0;
row = std::vector<JSVariant>();
column_count = sqlite3_column_count(statement);
row.reserve(column_count);

while (current_column < column_count) {
column_type = sqlite3_column_type(statement, current_column);
Expand Down Expand Up @@ -494,7 +493,7 @@ BridgeResult opsqlite_execute(std::string const &name, std::string const &query,
current_column++;
}

rows.push_back(row);
rows.emplace_back(std::move(row));
break;

case SQLITE_DONE:
Expand Down

0 comments on commit 60ac1b8

Please sign in to comment.