Skip to content

Commit

Permalink
async_hooks: don't set hook_fields[kTotals] to 0
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
danbev authored and MylesBorins committed Mar 20, 2018
1 parent 4b9914a commit 71b1c7f
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions lib/async_hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,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];
Expand All @@ -105,9 +104,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];
Expand Down

0 comments on commit 71b1c7f

Please sign in to comment.