Skip to content
This repository was archived by the owner on Feb 26, 2024. It is now read-only.

feat(performance): reuse microTaskQueue native promise#874

Merged
mhevery merged 1 commit intoangular:masterfrom
JiaLiPassion:promise
Aug 23, 2017
Merged

feat(performance): reuse microTaskQueue native promise#874
mhevery merged 1 commit intoangular:masterfrom
JiaLiPassion:promise

Conversation

@JiaLiPassion
Copy link
Copy Markdown
Collaborator

in zone.js we use native Promise when available to run microTaskQueue. in current version, we call

global[symbolPromise].resolve(0)[symbolThen](drainMicroTaskQueue);

so we will create a new native promise every time, in fact we only need to schedule a native async micro task to make sure drainMicroTaskQueue run async and run asap, we can reuse the promise for better performance.

if (!nativeMicroTaskQueuePromise) {
        if (global[symbolPromise]) {
          nativeMicroTaskQueuePromise = global[symbolPromise].resolve(0);
        }
      }
      if (nativeMicroTaskQueuePromise) {
        nativeMicroTaskQueuePromise[symbolThen](drainMicroTaskQueue);
     } ...

@mhevery mhevery merged commit 7ee8bcd into angular:master Aug 23, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants