mirror of
https://github.com/nodejs/node.git
synced 2026-10-14 10:26:26 -04:00
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: https://github.com/nodejs/node/pull/55373 Refs: https://github.com/nodejs/node/pull/54181 PR-URL: https://github.com/nodejs/node/pull/56908 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
This commit is contained in:
1 parent
d7aacbebd6
commit
1671921c4d
1 file changed
+10
-6
+10
-6
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user