Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
sqlite: restore changes from #55373
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
  • Loading branch information
cjihrig committed Feb 4, 2025
commit 71ad544bb6cb45a872597b04f2e27ccc053ca22a
16 changes: 10 additions & 6 deletions src/node_sqlite.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1161,18 +1161,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
Loading