Skip to content

Commit 71b1c7f

Browse files
danbevMylesBorins
authored andcommitted
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 <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 4b9914a commit 71b1c7f

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
@@ -77,12 +77,11 @@ class AsyncHook {
7777
return this;
7878

7979
const prev_kTotals = hook_fields[kTotals];
80-
hook_fields[kTotals] = 0;
8180

8281
// createHook() has already enforced that the callbacks are all functions,
8382
// so here simply increment the count of whether each callbacks exists or
8483
// not.
85-
hook_fields[kTotals] += hook_fields[kInit] += +!!this[init_symbol];
84+
hook_fields[kTotals] = hook_fields[kInit] += +!!this[init_symbol];
8685
hook_fields[kTotals] += hook_fields[kBefore] += +!!this[before_symbol];
8786
hook_fields[kTotals] += hook_fields[kAfter] += +!!this[after_symbol];
8887
hook_fields[kTotals] += hook_fields[kDestroy] += +!!this[destroy_symbol];
@@ -105,9 +104,8 @@ class AsyncHook {
105104
return this;
106105

107106
const prev_kTotals = hook_fields[kTotals];
108-
hook_fields[kTotals] = 0;
109107

110-
hook_fields[kTotals] += hook_fields[kInit] -= +!!this[init_symbol];
108+
hook_fields[kTotals] = hook_fields[kInit] -= +!!this[init_symbol];
111109
hook_fields[kTotals] += hook_fields[kBefore] -= +!!this[before_symbol];
112110
hook_fields[kTotals] += hook_fields[kAfter] -= +!!this[after_symbol];
113111
hook_fields[kTotals] += hook_fields[kDestroy] -= +!!this[destroy_symbol];

0 commit comments

Comments
 (0)