Skip to content
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

Replace for..in loops with index-based for loops #210

Conversation

xoundboy
Copy link

I had auto whitespace stripping enabled in Webstorm so there's a lot of whitespace removal too.. I hope this isn't going to be a problem. Thanks.

@palemieux
Copy link
Contributor

I plan to run the regression tests and get back to you.

@xoundboy
Copy link
Author

xoundboy commented Apr 1, 2021

Perfect, thanks

@palemieux
Copy link
Contributor

palemieux commented Apr 2, 2021

@xoundboy It looks like the changes might have gone a little too far. For example, styleAttrs and node.attributes and head.layout.regions are in fact dictionaries, so for..in is appropriate, right? In other words, only iteration over arrays should be changed to for(..;..;..).

Copy link
Contributor

@palemieux palemieux left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only loops over arrays should be changed since for..in is appropriate to loop over dictionaries. We also need to check for the existence of the array before starting the loop.

@@ -626,7 +626,7 @@

/* resolve desired timing for regions */

for (var region_i in doc.head.layout.regions) {
for (var region_i = 0; region_i < doc.head.layout.regions.length; region_i++) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tt.head.layout.regions is a dictionary, so this should in fact use for..in

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hi @palemieux sorry for the delay. Thanks for the review. I'll address your comments very soon.

@@ -575,7 +574,8 @@

var attrs = [];

for (var a in node.attributes) {
for (var a = 0; a < node.attributes.length; a++) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

node.attributes is a dictionary, so for..in is appropriate

@@ -751,7 +751,7 @@

} else {

for (var content_i in element.contents) {
for (var content_i = 0; content_i < element.contents.length; content_i++) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We probably need to check if contents exists.

@xoundboy
Copy link
Author

@palemieux I reverted my previous commit and started again. I just fixed those problems that were actually preventing subtitles from being parsed on Tizen TVs and dropped all of the other overzealous changes. I also resorted to the hasOwnProperty checks for safety. Thanks

@palemieux
Copy link
Contributor

@xoundboy Thanks. Apologies for the delay. I expanded your PR at #211 to include all for loops (and also corrected a bug). Any chance you might be able to try it on the tizen platform? The regression tests pass on my side.

@palemieux
Copy link
Contributor

@xoundboy Quick ping.

@palemieux
Copy link
Contributor

Replaced by #211

@palemieux palemieux closed this Sep 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants