diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2023-03-08 21:08:54 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-09 01:08:54 +0000 |
commit | 0f9df733499da4dea563342fc19e842f04bd7a40 (patch) | |
tree | 80706ade73ecb407072fbce133065b2c7ce37cea /runtime/js | |
parent | 25d98ca289af64f85759fe10c8808afbfb7011e3 (diff) |
perf: don't add unload event listener (#18082)
This commit changes how "unload" event is handled - before
this commit an event listener was added unconditionally in
the runtime bootstrapping function, which for some reason was
very expensive (0.3ms). Instead of adding an event listener,
a check was added to "dispatchEvent" function that performs
the same action (so it's only called if there's an event dispatched).
Diffstat (limited to 'runtime/js')
-rw-r--r-- | runtime/js/99_main.js | 11 |
1 files changed, 0 insertions, 11 deletions
diff --git a/runtime/js/99_main.js b/runtime/js/99_main.js index e3e7e64d8..d043f485e 100644 --- a/runtime/js/99_main.js +++ b/runtime/js/99_main.js @@ -30,7 +30,6 @@ const { ObjectSetPrototypeOf, PromiseResolve, Symbol, - SymbolFor, SymbolIterator, PromisePrototypeThen, SafeWeakMap, @@ -404,7 +403,6 @@ function bootstrapMainRuntime(runtimeOptions) { if (hasBootstrapped) { throw new Error("Worker runtime already bootstrapped"); } - performance.setTimeOrigin(DateNow()); globalThis_ = globalThis; @@ -451,15 +449,6 @@ function bootstrapMainRuntime(runtimeOptions) { core.setPromiseRejectCallback(promiseRejectCallback); - const isUnloadDispatched = SymbolFor("isUnloadDispatched"); - // Stores the flag for checking whether unload is dispatched or not. - // This prevents the recursive dispatches of unload events. - // See https://github.com/denoland/deno/issues/9201. - globalThis[isUnloadDispatched] = false; - globalThis.addEventListener("unload", () => { - globalThis_[isUnloadDispatched] = true; - }); - runtimeStart(runtimeOptions); setNumCpus(runtimeOptions.cpuCount); |