Skip to content

Commit 55d3be7

Browse files
addaleaxBethGriggs
authored andcommittedApr 16, 2019
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 <me@gus.host> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
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

+1-2
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

+1-1
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)