The GWT AST JMultiExpression and JS AST JsBinaryOperation with COMMA are used to condense simple statements into an expression, enabling further inlining work. However, from time to time these can emit code like (a=<expr>, a) in the JS output, which could be optimized to simply (a=<expr>). The value of both expressions is the same, with a few bytes saved.
This is a fairly easy change for JsStaticEval.trySimplifyComma, with a few simple improvements as a result.
As an example, SimpleEventBus gets this small improvement in the showcase:
if (!event) {
throw toJs(new NullPointerException('Cannot fire null event'));
}
try {
++this$static.firingDepth;
- handlers = (directHandlers = $getHandlerList(this$static, event.getAssociatedType(), null) , directHandlers);
+ handlers = directHandlers = $getHandlerList(this$static, event.getAssociatedType(), null);
causes = null;
it = this$static.isReverseOrder?handlers.listIterator(handlers.size()):handlers.listIterator();
while (this$static.isReverseOrder?it.hasPrevious():it.hasNext()) {
handler = this$static.isReverseOrder?it.previous():it.next();
try {
The GWT AST JMultiExpression and JS AST JsBinaryOperation with COMMA are used to condense simple statements into an expression, enabling further inlining work. However, from time to time these can emit code like
(a=<expr>, a)in the JS output, which could be optimized to simply(a=<expr>). The value of both expressions is the same, with a few bytes saved.This is a fairly easy change for JsStaticEval.trySimplifyComma, with a few simple improvements as a result.
As an example, SimpleEventBus gets this small improvement in the showcase:
if (!event) { throw toJs(new NullPointerException('Cannot fire null event')); } try { ++this$static.firingDepth; - handlers = (directHandlers = $getHandlerList(this$static, event.getAssociatedType(), null) , directHandlers); + handlers = directHandlers = $getHandlerList(this$static, event.getAssociatedType(), null); causes = null; it = this$static.isReverseOrder?handlers.listIterator(handlers.size()):handlers.listIterator(); while (this$static.isReverseOrder?it.hasPrevious():it.hasNext()) { handler = this$static.isReverseOrder?it.previous():it.next(); try {