Export to GitHub

google-web-toolkit - issue #599

PATCH to reduce size of generated JavaScript


Posted on Jan 16, 2007 by Helpful Rhino

GWT Release: 1.3.1

Detailed description: GWT's Java to JavaScript compiler currently places a space around every binary operator (=,+,-,==, etc), for the most part this isn't needed to distinguish operators from variables or expressions ("instanceof" and "in" are the exceptions). The one place I can think of where this may cause a problem is with unary operators (--,++,!,-) adjacent to binary operators because then it's not clear what some character sequences mean (in "foo---bar" is foo decremented or is bar?). To address this I added spaces before or after unary operators to prevent that confusion.

While not the optimal solution, this patch saves bytes because binary operators are more common than unary operators and even if they weren't unary operators only need one space to be unambiguous while binary operators currently use two spaces.

In my testing this patch saves almost 6% on the cache.html files sizes.

Links to the relevant GWT Developer Forum posts: http://groups.google.com/group/Google-Web-Toolkit-Contributors/browse_frm/thread/0a78989904807771/2aac13704f6e8d79?#2aac13704f6e8d79

Attachments

Comment #1

Posted on Jan 16, 2007 by Swift Hippo

Thanks, Sandy!

Comment #2

Posted on Feb 2, 2007 by Swift Hippo

This is great, I'm seeing the same reduction in size across the board.

Comment #3

Posted on Feb 5, 2007 by Swift Hippo

Submitted as r356.

Comment #4

Posted on May 24, 2007 by Massive Rabbit

(No comment was entered for this change.)

Comment #5

Posted on May 30, 2007 by Massive Rabbit

Changing to Fixed status with GWT 1.4 RC release

Comment #6

Posted on Apr 28, 2008 by Grumpy Horse

Comment #7

Posted on Feb 9, 2011 by Swift Ox

(No comment was entered for this change.)

Status: Fixed

Labels:
Type-Enhancement Priority-High Category-Compiler Milestone-1_4-RC