Skip to content

Commit ddcc00b

Browse files
committed
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. PR-URL: #19219 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent e16a2be commit ddcc00b

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

lib/async_hooks.js

+2-4
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,11 @@ class AsyncHook {
7474
return this;
7575

7676
const prev_kTotals = hook_fields[kTotals];
77-
hook_fields[kTotals] = 0;
7877

7978
// createHook() has already enforced that the callbacks are all functions,
8079
// so here simply increment the count of whether each callbacks exists or
8180
// not.
82-
hook_fields[kTotals] += hook_fields[kInit] += +!!this[init_symbol];
81+
hook_fields[kTotals] = hook_fields[kInit] += +!!this[init_symbol];
8382
hook_fields[kTotals] += hook_fields[kBefore] += +!!this[before_symbol];
8483
hook_fields[kTotals] += hook_fields[kAfter] += +!!this[after_symbol];
8584
hook_fields[kTotals] += hook_fields[kDestroy] += +!!this[destroy_symbol];
@@ -102,9 +101,8 @@ class AsyncHook {
102101
return this;
103102

104103
const prev_kTotals = hook_fields[kTotals];
105-
hook_fields[kTotals] = 0;
106104

107-
hook_fields[kTotals] += hook_fields[kInit] -= +!!this[init_symbol];
105+
hook_fields[kTotals] = hook_fields[kInit] -= +!!this[init_symbol];
108106
hook_fields[kTotals] += hook_fields[kBefore] -= +!!this[before_symbol];
109107
hook_fields[kTotals] += hook_fields[kAfter] -= +!!this[after_symbol];
110108
hook_fields[kTotals] += hook_fields[kDestroy] -= +!!this[destroy_symbol];

0 commit comments

Comments
 (0)