New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
馃殌Improve Mediapool initialization by cloning nodes #14055
Conversation
const mediaEl = this.mediaFactory_[type].call(this); | ||
mediaEl.setAttribute('pool-element', elId++); | ||
|
||
this.vsync_.mutate(() => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Drive-by: Allocating only one vsync
task is another small performance opt.
mediaEl.setAttribute('pool-element', elId++); | ||
|
||
this.vsync_.mutate(() => { | ||
for (let i = count; i > 0; i--) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Closure would compile into this faster reverse loop by default. Since i
is compared against below the compiler can no longer make order guarantees so it skips the optimization.
const sources = this.getDefaultSource_(type); | ||
mediaEl.setAttribute('pool-element', elId++); | ||
this.enqueueMediaElementTask_(mediaEl, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if we can enqueue this task for the seed and have it also work for the cloned nodes. I didn't wanna perf-test it so I opened #14058
* @private | ||
*/ | ||
forEachMediaType_(callback) { | ||
Object.keys(MediaType).forEach(callback); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also just driving by 馃殫...
Cloning nodes is faster than building them, so constructing a seed element makes sense for initialization.