-
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
perf(dash): improve readability and reduce number of loops in dash parser #5768
perf(dash): improve readability and reduce number of loops in dash parser #5768
Conversation
Incremental code coverage: 100.00% |
3de6bfd
to
685ec39
Compare
685ec39
to
9bd1040
Compare
lib/dash/dash_parser.js
Outdated
return []; | ||
} | ||
|
||
return adaptationSets.reduce((acc, currSet) => { |
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.
You could also use shaka.util.Functional.collapseArrays
for this.
Something like...
return adaptationSets.map((set) => {
return set.contentType == contentType ? set.streams : [];
}).reduce(shaka.util.Functional.collapseArrays, []);
If you think that doing it this way is better, though, instead I'll ask that you rename the variables on the method to all
and part
, as that is what we usually call them when reducing arrays.
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.
changed to (all, part)
…rser (shaka-project#5768) This change reduces the amount of loops in dash parser, and improves code readability, as checking config and creating an array of sets is in a separate method now. --------- Co-authored-by: Ivan Kohut <ivan.kohut@lamin.ar>
This change reduces the amount of loops in dash parser, and improves code readability, as checking config and creating an array of sets is in a separate method now.