Skip to content

Commit 6067bea

Browse files
cjihrigRafaelGSS
authored andcommitted
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 PR-URL: #56908 Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]>
1 parent 824cf35 commit 6067bea

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/node_sqlite.cc

+10-6
Original file line numberDiff line numberDiff line change
@@ -1223,18 +1223,22 @@ void StatementSync::All(const FunctionCallbackInfo<Value>& args) {
12231223
auto reset = OnScopeLeave([&]() { sqlite3_reset(stmt->statement_); });
12241224
int num_cols = sqlite3_column_count(stmt->statement_);
12251225
LocalVector<Value> rows(isolate);
1226+
LocalVector<Name> row_keys(isolate);
12261227
while ((r = sqlite3_step(stmt->statement_)) == SQLITE_ROW) {
1227-
LocalVector<Name> row_keys(isolate);
1228-
row_keys.reserve(num_cols);
1228+
if (row_keys.size() == 0) {
1229+
row_keys.reserve(num_cols);
1230+
for (int i = 0; i < num_cols; ++i) {
1231+
Local<Name> key;
1232+
if (!stmt->ColumnNameToName(i).ToLocal(&key)) return;
1233+
row_keys.emplace_back(key);
1234+
}
1235+
}
1236+
12291237
LocalVector<Value> row_values(isolate);
12301238
row_values.reserve(num_cols);
1231-
12321239
for (int i = 0; i < num_cols; ++i) {
1233-
Local<Name> key;
1234-
if (!stmt->ColumnNameToName(i).ToLocal(&key)) return;
12351240
Local<Value> val;
12361241
if (!stmt->ColumnToValue(i).ToLocal(&val)) return;
1237-
row_keys.emplace_back(key);
12381242
row_values.emplace_back(val);
12391243
}
12401244

0 commit comments

Comments
 (0)