Skip to content

Commit 9384897

Browse files
committed
src: update std::vector<v8::Local<T>> to use v8::LocalVector<T>
According to V8's public API documentation, local handles (i.e., objects of type v8::Local<T>) "should never be allocated on the heap". This replaces the usage of heap-allocated data structures containing instances of `v8::Local`, specifically the `std::vector<v8::Local<v8::String>>` with recently introduced `v8::LocalVector<T>`. This is first of the series of commits to replace all `std::vector<v8::Local<T>>` to use `v8::LocalVector<T>`.
1 parent 046781e commit 9384897

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/node_builtins.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ void BuiltinLoader::AddExternalizedBuiltin(const char* id,
258258
MaybeLocal<Function> BuiltinLoader::LookupAndCompileInternal(
259259
Local<Context> context,
260260
const char* id,
261-
std::vector<Local<String>>* parameters,
261+
v8::LocalVector<String>* parameters,
262262
Realm* optional_realm) {
263263
Isolate* isolate = context->GetIsolate();
264264
EscapableHandleScope scope(isolate);
@@ -382,8 +382,8 @@ void BuiltinLoader::SaveCodeCache(const char* id, Local<Function> fun) {
382382
MaybeLocal<Function> BuiltinLoader::LookupAndCompile(Local<Context> context,
383383
const char* id,
384384
Realm* optional_realm) {
385-
std::vector<Local<String>> parameters;
386385
Isolate* isolate = context->GetIsolate();
386+
v8::LocalVector<String> parameters(isolate);
387387
// Detects parameters of the scripts based on module ids.
388388
// internal/bootstrap/realm: process, getLinkedBinding,
389389
// getInternalBinding, primordials
@@ -497,7 +497,7 @@ MaybeLocal<Value> BuiltinLoader::CompileAndCall(Local<Context> context,
497497
MaybeLocal<Function> BuiltinLoader::LookupAndCompile(
498498
Local<Context> context,
499499
const char* id,
500-
std::vector<Local<String>>* parameters,
500+
v8::LocalVector<String>* parameters,
501501
Realm* optional_realm) {
502502
return LookupAndCompileInternal(context, id, parameters, optional_realm);
503503
}

src/node_builtins.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ class NODE_EXTERN_PRIVATE BuiltinLoader {
101101
v8::MaybeLocal<v8::Function> LookupAndCompile(
102102
v8::Local<v8::Context> context,
103103
const char* id,
104-
std::vector<v8::Local<v8::String>>* parameters,
104+
v8::LocalVector<v8::String>* parameters,
105105
Realm* optional_realm);
106106

107107
v8::MaybeLocal<v8::Value> CompileAndCall(v8::Local<v8::Context> context,
@@ -159,7 +159,7 @@ class NODE_EXTERN_PRIVATE BuiltinLoader {
159159
v8::MaybeLocal<v8::Function> LookupAndCompileInternal(
160160
v8::Local<v8::Context> context,
161161
const char* id,
162-
std::vector<v8::Local<v8::String>>* parameters,
162+
v8::LocalVector<v8::String>* parameters,
163163
Realm* optional_realm);
164164
void SaveCodeCache(const char* id, v8::Local<v8::Function> fn);
165165

0 commit comments

Comments
 (0)