Skip to content

Commit

Permalink
sqlite: restore changes from #55373
Browse files Browse the repository at this point in the history
PR #55373 introduced a performance improvement for the all()
method of prepared statements. Those changes appear to have been
accidentally overwritten in #54181. This change restores the
overwritten code.

Refs: #55373
Refs: #54181
PR-URL: #56908
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
  • Loading branch information
cjihrig authored Feb 6, 2025
1 parent d7aacbe commit 1671921
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/node_sqlite.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1510,18 +1510,22 @@ void StatementSync::All(const FunctionCallbackInfo<Value>& args) {
auto reset = OnScopeLeave([&]() { sqlite3_reset(stmt->statement_); });
int num_cols = sqlite3_column_count(stmt->statement_);
LocalVector<Value> rows(isolate);
LocalVector<Name> row_keys(isolate);
while ((r = sqlite3_step(stmt->statement_)) == SQLITE_ROW) {
LocalVector<Name> row_keys(isolate);
row_keys.reserve(num_cols);
if (row_keys.size() == 0) {
row_keys.reserve(num_cols);
for (int i = 0; i < num_cols; ++i) {
Local<Name> key;
if (!stmt->ColumnNameToName(i).ToLocal(&key)) return;
row_keys.emplace_back(key);
}
}

LocalVector<Value> row_values(isolate);
row_values.reserve(num_cols);

for (int i = 0; i < num_cols; ++i) {
Local<Name> key;
if (!stmt->ColumnNameToName(i).ToLocal(&key)) return;
Local<Value> val;
if (!stmt->ColumnToValue(i).ToLocal(&val)) return;
row_keys.emplace_back(key);
row_values.emplace_back(val);
}

Expand Down

0 comments on commit 1671921

Please sign in to comment.