-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Fix selectVariantsByLabel using src= #5154
Conversation
Incremental code coverage: 0.00% |
const audioTracks = Array.from(this.video_.audioTracks); | ||
|
||
let trackMatch = null; | ||
|
||
for (const audioTrack of audioTracks) { | ||
if (audioTrack.label == label) { | ||
trackMatch = audioTrack; | ||
} | ||
} | ||
if (trackMatch) { | ||
this.switchHtml5Track_(trackMatch); | ||
} |
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.
Just curious: Is there any reason we use for/of over built in Array methods?
const trackMatch = Array.from(this.video_.audioTracks)
.find(track => track.label == label);
if (trackMatch) {
this.switchHtml5Track_(trackMatch);
}
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 have done it like this for consistency with the rest of the code
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.
@joeyparrish what do you think?
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.
The comment really was just a curiosity. I don't see anything wrong with this.
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 don't know if it matters or not. I seem to recall that callback-based methods might have a performance penalty, maybe use more memory, I don't know. We used to do a lot of array.forEach() when the codebase was all ES5, but there was some issue that caused us to go to for-of when we upgraded to ES6+. I really can't recall what it was, and I could be misremembering the whole thing. I won't make it a policy to use one style or the other without a very good reason, and I can't remember a reason.
No description provided.