mirror of
https://github.com/zebrajr/node.git
synced 2025-12-06 00:20:08 +01:00
lib: remove redundant destroyHook checks
PR-URL: https://github.com/nodejs/node/pull/60120 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de>
This commit is contained in:
parent
0fb040603b
commit
15278252bb
|
|
@ -532,7 +532,7 @@ function emitAfterScript(asyncId) {
|
||||||
|
|
||||||
function emitDestroyScript(asyncId) {
|
function emitDestroyScript(asyncId) {
|
||||||
// Return early if there are no destroy callbacks, or invalid asyncId.
|
// Return early if there are no destroy callbacks, or invalid asyncId.
|
||||||
if (!hasHooks(kDestroy) || asyncId <= 0)
|
if (!hasHooks(kDestroy) || !(asyncId > 0))
|
||||||
return;
|
return;
|
||||||
async_wrap.queueDestroyAsyncId(asyncId);
|
async_wrap.queueDestroyAsyncId(asyncId);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,6 @@ const {
|
||||||
getDefaultTriggerAsyncId,
|
getDefaultTriggerAsyncId,
|
||||||
newAsyncId,
|
newAsyncId,
|
||||||
initHooksExist,
|
initHooksExist,
|
||||||
destroyHooksExist,
|
|
||||||
emitInit,
|
emitInit,
|
||||||
emitBefore,
|
emitBefore,
|
||||||
emitAfter,
|
emitAfter,
|
||||||
|
|
@ -94,8 +93,7 @@ function processTicksAndRejections() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
if (destroyHooksExist())
|
emitDestroy(asyncId);
|
||||||
emitDestroy(asyncId);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
emitAfter(asyncId);
|
emitAfter(asyncId);
|
||||||
|
|
|
||||||
|
|
@ -92,7 +92,6 @@ const {
|
||||||
getDefaultTriggerAsyncId,
|
getDefaultTriggerAsyncId,
|
||||||
newAsyncId,
|
newAsyncId,
|
||||||
initHooksExist,
|
initHooksExist,
|
||||||
destroyHooksExist,
|
|
||||||
// The needed emit*() functions.
|
// The needed emit*() functions.
|
||||||
emitInit,
|
emitInit,
|
||||||
emitBefore,
|
emitBefore,
|
||||||
|
|
@ -508,8 +507,7 @@ function getTimerCallbacks(runNextTicks) {
|
||||||
} finally {
|
} finally {
|
||||||
immediate._onImmediate = null;
|
immediate._onImmediate = null;
|
||||||
|
|
||||||
if (destroyHooksExist())
|
emitDestroy(asyncId);
|
||||||
emitDestroy(asyncId);
|
|
||||||
|
|
||||||
outstandingQueue.head = immediate = immediate._idleNext;
|
outstandingQueue.head = immediate = immediate._idleNext;
|
||||||
}
|
}
|
||||||
|
|
@ -585,8 +583,7 @@ function getTimerCallbacks(runNextTicks) {
|
||||||
if (timer[kRefed])
|
if (timer[kRefed])
|
||||||
timeoutInfo[0]--;
|
timeoutInfo[0]--;
|
||||||
|
|
||||||
if (destroyHooksExist())
|
emitDestroy(asyncId);
|
||||||
emitDestroy(asyncId);
|
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
@ -621,8 +618,7 @@ function getTimerCallbacks(runNextTicks) {
|
||||||
if (timer[kRefed])
|
if (timer[kRefed])
|
||||||
timeoutInfo[0]--;
|
timeoutInfo[0]--;
|
||||||
|
|
||||||
if (destroyHooksExist())
|
emitDestroy(asyncId);
|
||||||
emitDestroy(asyncId);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -63,7 +63,6 @@ let timersPromises;
|
||||||
let timers;
|
let timers;
|
||||||
|
|
||||||
const {
|
const {
|
||||||
destroyHooksExist,
|
|
||||||
// The needed emit*() functions.
|
// The needed emit*() functions.
|
||||||
emitDestroy,
|
emitDestroy,
|
||||||
} = require('internal/async_hooks');
|
} = require('internal/async_hooks');
|
||||||
|
|
@ -78,9 +77,7 @@ function unenroll(item) {
|
||||||
if (item[kHasPrimitive])
|
if (item[kHasPrimitive])
|
||||||
delete knownTimersById[item[async_id_symbol]];
|
delete knownTimersById[item[async_id_symbol]];
|
||||||
|
|
||||||
// Fewer checks may be possible, but these cover everything.
|
emitDestroy(item[async_id_symbol]);
|
||||||
if (destroyHooksExist() && item[async_id_symbol] !== undefined)
|
|
||||||
emitDestroy(item[async_id_symbol]);
|
|
||||||
|
|
||||||
L.remove(item);
|
L.remove(item);
|
||||||
|
|
||||||
|
|
@ -239,9 +236,7 @@ function clearImmediate(immediate) {
|
||||||
}
|
}
|
||||||
immediate[kRefed] = null;
|
immediate[kRefed] = null;
|
||||||
|
|
||||||
if (destroyHooksExist() && immediate[async_id_symbol] !== undefined) {
|
emitDestroy(immediate[async_id_symbol]);
|
||||||
emitDestroy(immediate[async_id_symbol]);
|
|
||||||
}
|
|
||||||
|
|
||||||
immediate._onImmediate = null;
|
immediate._onImmediate = null;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
Error: test
|
Error: test
|
||||||
at one (*fixtures*async-error.js:4:9)
|
at one (*fixtures*async-error.js:4:9)
|
||||||
at two (*fixtures*async-error.js:17:9)
|
at two (*fixtures*async-error.js:17:9)
|
||||||
at process.processTicksAndRejections (node:internal*process*task_queues:105:5)
|
at process.processTicksAndRejections (node:internal*process*task_queues:103:5)
|
||||||
at async three (*fixtures*async-error.js:20:3)
|
at async three (*fixtures*async-error.js:20:3)
|
||||||
at async four (*fixtures*async-error.js:24:3)
|
at async four (*fixtures*async-error.js:24:3)
|
||||||
at async main (*async_error_nexttick_main.js:7:5)
|
at async main (*async_error_nexttick_main.js:7:5)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user