-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
tweak do-while loops #1452
tweak do-while loops #1452
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1749,8 +1749,14 @@ merge(Compressor.prototype, { | |
extract_declarations_from_unreachable_code(compressor, self.body, a); | ||
return make_node(AST_BlockStatement, self, { body: a }); | ||
} | ||
} else { | ||
// self instanceof AST_Do | ||
return self.body; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. But I am not certain about the handling of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll get rid of this and add new test cases to address #1532. Then we can revisit this optimisation at a later date. |
||
} | ||
} | ||
if (self instanceof AST_While) { | ||
return make_node(AST_For, self, self).transform(compressor); | ||
} | ||
return self; | ||
}); | ||
|
||
|
@@ -1799,16 +1805,6 @@ merge(Compressor.prototype, { | |
} | ||
}; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is the equivalent logic for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
It is technically not calling There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see. Thanks. |
||
|
||
OPT(AST_While, function(self, compressor) { | ||
if (!compressor.option("loops")) return self; | ||
self = AST_DWLoop.prototype.optimize.call(self, compressor); | ||
if (self instanceof AST_While) { | ||
if_break_in_loop(self, compressor); | ||
self = make_node(AST_For, self, self).transform(compressor); | ||
} | ||
return self; | ||
}); | ||
|
||
OPT(AST_For, function(self, compressor){ | ||
var cond = self.condition; | ||
if (cond) { | ||
|
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.
Please add comment:
// self instanceof AST_Do
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.
Done.