Skip to content
This repository has been archived by the owner on Jul 2, 2024. It is now read-only.

Use for instead of forEach and reset array instead of allocating new #2

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

kurtextrem
Copy link

@kurtextrem kurtextrem commented Sep 20, 2018

This makes everything a little faster in benchmarks, however it uses more bytes.

If you want to take the trade-off (slightly more bytes, but no new array allocation needed) for https://github.com/GoogleChromeLabs/idlize/blob/master/IdleQueue.mjs as well I can PR too.

This makes everything a little faster in benchmarks, however it uses more bytes.
Copy link

@Lxxyx Lxxyx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

forget to delete code

@@ -31,7 +31,8 @@ const createQueueMicrotaskViaMutationObserver = () => {
let microtaskQueue = [];
const observer = new MutationObserver(() => {
microtaskQueue.forEach((microtask) => microtask());
microtaskQueue = [];
for (let x = 0; x < microtaskQueue.length; ++x) microtaskQueue[x]();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems microtaskQueue run twice. You forget delete forEach tasks.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oups, yes, thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants