From 07cd9c672dbe2959e3ba2c99f2065203dd348872 Mon Sep 17 00:00:00 2001 From: Daniel Bevenius Date: Wed, 7 Mar 2018 19:59:23 +0100 Subject: [PATCH 1/2] async_hooks: don't set hook_fields[kTotals] to 0 This commit removes the setting of hook_field[kTotals] to szero in AsyncHook's enable function. As far as I can tell this would not be required if the setting of this field is done with the assignment operator instead of using the addition assignment operator. --- lib/async_hooks.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/async_hooks.js b/lib/async_hooks.js index 0c425e694584eb..aa3b5eb374dc13 100644 --- a/lib/async_hooks.js +++ b/lib/async_hooks.js @@ -74,12 +74,11 @@ class AsyncHook { return this; const prev_kTotals = hook_fields[kTotals]; - hook_fields[kTotals] = 0; // createHook() has already enforced that the callbacks are all functions, // so here simply increment the count of whether each callbacks exists or // not. - hook_fields[kTotals] += hook_fields[kInit] += +!!this[init_symbol]; + hook_fields[kTotals] = hook_fields[kInit] += +!!this[init_symbol]; hook_fields[kTotals] += hook_fields[kBefore] += +!!this[before_symbol]; hook_fields[kTotals] += hook_fields[kAfter] += +!!this[after_symbol]; hook_fields[kTotals] += hook_fields[kDestroy] += +!!this[destroy_symbol]; From 77a93132dbf5c5c032a53450cff0062d571c1264 Mon Sep 17 00:00:00 2001 From: Daniel Bevenius Date: Thu, 8 Mar 2018 14:09:24 +0100 Subject: [PATCH 2/2] squash: same changes for disable --- lib/async_hooks.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/async_hooks.js b/lib/async_hooks.js index aa3b5eb374dc13..f32c9131850c78 100644 --- a/lib/async_hooks.js +++ b/lib/async_hooks.js @@ -101,9 +101,8 @@ class AsyncHook { return this; const prev_kTotals = hook_fields[kTotals]; - hook_fields[kTotals] = 0; - hook_fields[kTotals] += hook_fields[kInit] -= +!!this[init_symbol]; + hook_fields[kTotals] = hook_fields[kInit] -= +!!this[init_symbol]; hook_fields[kTotals] += hook_fields[kBefore] -= +!!this[before_symbol]; hook_fields[kTotals] += hook_fields[kAfter] -= +!!this[after_symbol]; hook_fields[kTotals] += hook_fields[kDestroy] -= +!!this[destroy_symbol];