Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit a854bb3

Browse filesBrowse files
Flarnadanielleadams
authored andcommitted
node-api: create reference only when needed
Optimize napi_create_external() to create the reference for calling finalizer only if user actually provides a finalizer callback. PR-URL: #44827 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Daeyeon Jeong <daeyeon.dev@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent dc2af26 commit a854bb3
Copy full SHA for a854bb3

File tree

Expand file treeCollapse file tree

1 file changed

+6
-4
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+6
-4
lines changed
Open diff view settings
Collapse file

‎src/js_native_api_v8.cc‎

Copy file name to clipboardExpand all lines: src/js_native_api_v8.cc
+6-4Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2387,10 +2387,12 @@ napi_status NAPI_CDECL napi_create_external(napi_env env,
23872387

23882388
v8::Local<v8::Value> external_value = v8::External::New(isolate, data);
23892389

2390-
// The Reference object will delete itself after invoking the finalizer
2391-
// callback.
2392-
v8impl::Reference::New(
2393-
env, external_value, 0, true, finalize_cb, data, finalize_hint);
2390+
if (finalize_cb) {
2391+
// The Reference object will delete itself after invoking the finalizer
2392+
// callback.
2393+
v8impl::Reference::New(
2394+
env, external_value, 0, true, finalize_cb, data, finalize_hint);
2395+
}
23942396

23952397
*result = v8impl::JsValueFromV8LocalValue(external_value);
23962398

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.