async_hooks: don't read resource if ALS is disabled

Only call executionAsyncResource() in getStore() if the ALS instance is
enabled because the resource is not needed otherwise.

PR-URL: https://github.com/nodejs/node/pull/34617
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
This commit is contained in:
Gerhard Stoebich 2020-08-03 23:52:58 +02:00
parent 48249889b6
commit a4e1755df2
1 changed files with 1 additions and 1 deletions

View File

@ -313,8 +313,8 @@ class AsyncLocalStorage {
}
getStore() {
const resource = executionAsyncResource();
if (this.enabled) {
const resource = executionAsyncResource();
return resource[this.kResourceStore];
}
}