mirror of
https://github.com/zebrajr/node.git
synced 2026-01-15 12:15:26 +00:00
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: https://github.com/nodejs/node/pull/23844 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Matheus Marchini <mat@mmarchini.me> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
This commit is contained in:
@@ -186,20 +186,20 @@ inline void Environment::AsyncHooks::clear_async_id_stack() {
|
||||
inline Environment::AsyncHooks::DefaultTriggerAsyncIdScope
|
||||
::DefaultTriggerAsyncIdScope(Environment* env,
|
||||
double default_trigger_async_id)
|
||||
: async_id_fields_ref_(env->async_hooks()->async_id_fields()) {
|
||||
: async_hooks_(env->async_hooks()) {
|
||||
if (env->async_hooks()->fields()[AsyncHooks::kCheck] > 0) {
|
||||
CHECK_GE(default_trigger_async_id, 0);
|
||||
}
|
||||
|
||||
old_default_trigger_async_id_ =
|
||||
async_id_fields_ref_[AsyncHooks::kDefaultTriggerAsyncId];
|
||||
async_id_fields_ref_[AsyncHooks::kDefaultTriggerAsyncId] =
|
||||
async_hooks_->async_id_fields()[AsyncHooks::kDefaultTriggerAsyncId];
|
||||
async_hooks_->async_id_fields()[AsyncHooks::kDefaultTriggerAsyncId] =
|
||||
default_trigger_async_id;
|
||||
}
|
||||
|
||||
inline Environment::AsyncHooks::DefaultTriggerAsyncIdScope
|
||||
::~DefaultTriggerAsyncIdScope() {
|
||||
async_id_fields_ref_[AsyncHooks::kDefaultTriggerAsyncId] =
|
||||
async_hooks_->async_id_fields()[AsyncHooks::kDefaultTriggerAsyncId] =
|
||||
old_default_trigger_async_id_;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user