perf: hold V8FunctionInvoker args in a std::array (#43752)

perf: hold V8FunctionInvoker args in a std::array
This commit is contained in:
Charles Kerr 2024-09-18 16:23:29 -05:00 committed by GitHub
parent 8cff5a7d20
commit 5904d31264
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -5,8 +5,8 @@
#ifndef ELECTRON_SHELL_COMMON_GIN_HELPER_CALLBACK_H_
#define ELECTRON_SHELL_COMMON_GIN_HELPER_CALLBACK_H_
#include <array>
#include <utility>
#include <vector>
#include "base/functional/bind.h"
#include "shell/common/gin_converters/std_converter.h"
@ -54,7 +54,7 @@ struct V8FunctionInvoker<v8::Local<v8::Value>(ArgTypes...)> {
isolate, context->GetMicrotaskQueue(), true,
v8::MicrotasksScope::kRunMicrotasks};
v8::Context::Scope context_scope(context);
std::vector<v8::Local<v8::Value>> args{
std::array<v8::Local<v8::Value>, sizeof...(raw)> args{
gin::ConvertToV8(isolate, std::forward<ArgTypes>(raw))...};
v8::MaybeLocal<v8::Value> ret = holder->Call(
context, holder, args.size(), args.empty() ? nullptr : &args.front());
@ -80,7 +80,7 @@ struct V8FunctionInvoker<void(ArgTypes...)> {
isolate, context->GetMicrotaskQueue(), true,
v8::MicrotasksScope::kRunMicrotasks};
v8::Context::Scope context_scope(context);
std::vector<v8::Local<v8::Value>> args{
std::array<v8::Local<v8::Value>, sizeof...(raw)> args{
gin::ConvertToV8(isolate, std::forward<ArgTypes>(raw))...};
holder
->Call(context, holder, args.size(),
@ -105,7 +105,7 @@ struct V8FunctionInvoker<ReturnType(ArgTypes...)> {
isolate, context->GetMicrotaskQueue(), true,
v8::MicrotasksScope::kRunMicrotasks};
v8::Context::Scope context_scope(context);
std::vector<v8::Local<v8::Value>> args{
std::array<v8::Local<v8::Value>, sizeof...(raw)> args{
gin::ConvertToV8(isolate, std::forward<ArgTypes>(raw))...};
v8::Local<v8::Value> result;
auto maybe_result = holder->Call(context, holder, args.size(),