Skip to content

Commit 55d3be7

Browse files
addaleaxBethGriggs
authored andcommitted
src: simplify native immediate by using v8::Global
Unlike `node::Persistent`, `v8::Global` has move semantics and can be used directly in STL containers. PR-URL: #26254 Reviewed-By: Gus Caplan <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Joyee Cheung <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 4f60364 commit 55d3be7

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

src/env-inl.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -590,8 +590,7 @@ void Environment::CreateImmediate(native_immediate_callback cb,
590590
native_immediate_callbacks_.push_back({
591591
cb,
592592
data,
593-
std::unique_ptr<Persistent<v8::Object>>(obj.IsEmpty() ?
594-
nullptr : new Persistent<v8::Object>(isolate_, obj)),
593+
v8::Global<v8::Object>(isolate_, obj),
595594
ref
596595
});
597596
immediate_info()->count_inc(1);

src/env.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -977,7 +977,7 @@ class Environment {
977977
struct NativeImmediateCallback {
978978
native_immediate_callback cb_;
979979
void* data_;
980-
std::unique_ptr<Persistent<v8::Object>> keep_alive_;
980+
v8::Global<v8::Object> keep_alive_;
981981
bool refed_;
982982
};
983983
std::vector<NativeImmediateCallback> native_immediate_callbacks_;

0 commit comments

Comments
 (0)