Skip to content

Commit 44a1993

Browse files
addaleaxMylesBorins
authored andcommitted
src: avoid extra Persistent in DefaultTriggerAsyncIdScope
Instead of getting a reference to the main `AliasedBuffer`, which would always unnecesarily allocate and destroy a `Persistent` handle, store and use a reference to the owning object. PR-URL: #23844 Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Matheus Marchini <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Anatoli Papirovski <[email protected]>
1 parent 72d2d2c commit 44a1993

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/env-inl.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -186,20 +186,20 @@ inline void Environment::AsyncHooks::clear_async_id_stack() {
186186
inline Environment::AsyncHooks::DefaultTriggerAsyncIdScope
187187
::DefaultTriggerAsyncIdScope(Environment* env,
188188
double default_trigger_async_id)
189-
: async_id_fields_ref_(env->async_hooks()->async_id_fields()) {
189+
: async_hooks_(env->async_hooks()) {
190190
if (env->async_hooks()->fields()[AsyncHooks::kCheck] > 0) {
191191
CHECK_GE(default_trigger_async_id, 0);
192192
}
193193

194194
old_default_trigger_async_id_ =
195-
async_id_fields_ref_[AsyncHooks::kDefaultTriggerAsyncId];
196-
async_id_fields_ref_[AsyncHooks::kDefaultTriggerAsyncId] =
195+
async_hooks_->async_id_fields()[AsyncHooks::kDefaultTriggerAsyncId];
196+
async_hooks_->async_id_fields()[AsyncHooks::kDefaultTriggerAsyncId] =
197197
default_trigger_async_id;
198198
}
199199

200200
inline Environment::AsyncHooks::DefaultTriggerAsyncIdScope
201201
::~DefaultTriggerAsyncIdScope() {
202-
async_id_fields_ref_[AsyncHooks::kDefaultTriggerAsyncId] =
202+
async_hooks_->async_id_fields()[AsyncHooks::kDefaultTriggerAsyncId] =
203203
old_default_trigger_async_id_;
204204
}
205205

src/env.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,7 @@ class Environment {
482482
~DefaultTriggerAsyncIdScope();
483483

484484
private:
485-
AliasedBuffer<double, v8::Float64Array> async_id_fields_ref_;
485+
AsyncHooks* async_hooks_;
486486
double old_default_trigger_async_id_;
487487

488488
DISALLOW_COPY_AND_ASSIGN(DefaultTriggerAsyncIdScope);

0 commit comments

Comments
 (0)