Skip to content

Commit 3372130

Browse files
committed
Improved RowToJS performance by removing Napi::String::New instantiation
refs https://github.com/nodejs/node-addon-api/blob/main/doc/object.md#set - according to the node-addon-api docs, you can set various things as the key for a Napi::Object, including a std::string ref - instantiating a `Napi::String::New` is quite heavy, especially when we're doing it for every row we return, so we can avoid doing that and speed up the function - locally, this speeds up the benchmark by 5-15% (a lot of variance) but YMMV
1 parent 77b327c commit 3372130

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/statement.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -814,7 +814,7 @@ Napi::Value Statement::RowToJS(Napi::Env env, Row* row) {
814814
} break;
815815
}
816816

817-
(result).Set(Napi::String::New(env, field->name.c_str()), value);
817+
result.Set(field->name, value);
818818
}
819819

820820
return scope.Escape(result);

0 commit comments

Comments
 (0)