mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-23 02:05:42 +00:00
46fd11fd0d
`Async.jankYielder` is known to, unfortunately, cause jank by creating a lot of immediately resolved promises that must be then GCed. For a collection of 50 items, it will create 50 promises and 49 of them will immediately resolve. Instead of `Async.jankYielder`, we now have `Async.yieldState`, which simply keeps track of whether or not the caller should yield to the event loop. Two higher level looping constructs are built on top of it: * `Async.yieldingIterator`, which has been rewritten to not create extraneous promises; and * `Async.yieldingForEach`, which is a replacement for awaiting `Async.jankYielder` in a loop. Instead, it accepts the loop body as a function. Each of these can share an instance of an `Async.yieldState`, which allows an object with multiple loops to yield every N iterations overall, instead of every N iterations of each loop, which keeps the behaviour of using one `Async.jankYielders` in multiple places. Differential Revision: https://phabricator.services.mozilla.com/D26229 --HG-- extra : moz-landing-system : lando |
||
---|---|---|
.. | ||
cld2 | ||
content | ||
test | ||
BingTranslator.jsm | ||
GoogleTranslator.jsm | ||
LanguageDetector.jsm | ||
moz.build | ||
Translation.jsm | ||
TranslationContentHandler.jsm | ||
TranslationDocument.jsm | ||
YandexTranslator.jsm |