perf: hold Emit() arg arrays in a std::array (#43750)

* refactor: CallMethodWithArgs() now takes a span of value handles

* perf: use std::array instead of std::vector to hold Emit arg parameter packs

* chore: remove unused gin_helper::EmitEvent(iso, obj, name, span<Local>)
This commit is contained in:
Charles Kerr 2024-09-18 09:40:14 -05:00 committed by GitHub
parent 02fd8bbcc1
commit d897359b82
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 13 additions and 26 deletions

View file

@ -9,10 +9,11 @@
namespace gin_helper::internal {
v8::Local<v8::Value> CallMethodWithArgs(v8::Isolate* isolate,
v8::Local<v8::Object> obj,
const char* method,
ValueVector* args) {
v8::Local<v8::Value> CallMethodWithArgs(
v8::Isolate* isolate,
v8::Local<v8::Object> obj,
const char* method,
const base::span<v8::Local<v8::Value>> args) {
v8::EscapableHandleScope handle_scope{isolate};
// CallbackScope and MakeCallback both require an active node::Environment
@ -29,7 +30,7 @@ v8::Local<v8::Value> CallMethodWithArgs(v8::Isolate* isolate,
// node::MakeCallback will also run pending tasks in Node.js.
v8::MaybeLocal<v8::Value> ret = node::MakeCallback(
isolate, obj, method, args->size(), args->data(), {0, 0});
isolate, obj, method, args.size(), args.data(), {0, 0});
// If the JS function throws an exception (doesn't return a value) the result
// of MakeCallback will be empty and therefore ToLocal will be false, in this