Skip to content

Compiler to remove every last possible space or ;Β #986

Closed

Description

@dankurka

Originally reported on Google Code with ID 978

Found in GWT Release:
Trunk r958

Detailed description:
There exist a few remaining cases in which the compiler in OBFUSCATED mode
could get rid of some white-space or semi-colons. There's not much left
after #968, but here are some suggestions:

1) Last semi-colon before closing brace (Note: this represents 3% of the
KitchenSink!)
   {return a;}  --> {return a}

2) Keywords (e.g. new|delete|case|else|function|return|throw|var) may be
immediately followed by certain characters, e.g. ' " [ ( { + - ! ~ ;
   return 'text'  -->  return'text'
   return ;  --> return;
   return [a,b]  ->  return[a,b]

3) Certain operator combinations
   a&& !b  -->  a&&!b
   a|| !b  -->  a||!b

4) Negative numbers
   (-1)  ->  -1

5) Not equal (combined with negative numbers)
   a!= (-1)  -->  a!=-1

6) The hard coded header and footer on the *.cache.html files could lose a
few hand trimmed bytes:
  * lose white-space
  * comma separate three var delcarations: $doc, $wnd, $moduleName
  * possibly lose <head>, or was there a reason to have one script tag  in
the head, and one in the body?
  * lose <font> tag; we're bean counting, right?

Reported by fredsa on 2007-04-26 03:18:36

Activity

  1. dankurka commented on Jun 10, 2015

    @dankurka
    ContributorAuthor
    Okay, this *is* feature creep, but c'mon! 
    
    If just removing ';' before closing braces is 3% in KS, then it seems like a pretty
    low-risk tweak and a nice little peephole improvement? Scott, please take a look. If
    it isn't pretty easy, let's punt. I don't think we should try anything other than #1
    for 1.4.
    

    Reported by gwt.team.bruce on 2007-04-26 14:32:18

    • Labels added: Milestone-1_4_RC
  2. self-assigned this
    on Jun 10, 2015
  3. dankurka commented on Jun 10, 2015

    @dankurka
    ContributorAuthor

    Reported by gwt.team.scottb on 2007-04-26 16:10:34

    • Status changed: Accepted
  4. dankurka commented on Jun 10, 2015

    @dankurka
    ContributorAuthor

    Reported by gwt.team.scottb on 2007-04-26 16:10:48

    • Labels added: Type-Enhancement
    • Labels removed: Type-Defect
  5. dankurka commented on Jun 10, 2015

    @dankurka
    ContributorAuthor

    Reported by gwt.team.morrildl on 2007-04-27 13:52:09

    • Labels added: Category-Compiler
  6. dankurka commented on Jun 10, 2015

    @dankurka
    ContributorAuthor
    I don't think we can do this for 1.4 unless we put more research into this.  Doing it
    the trivial way, I ended up with a syntax error in IE but ending a function with:
    
    ...;if(a)}
    
    Apparently, it's not ok to end with no semi if the last statement is an empty if. Now
    granted, dead code should have probably eliminated the if (although it could happen
    in JSNI code as well), but still, it seems risky to put this in without a more
    thorough investigation.
    
    I've attached a patch file representing the work in progress.
    
    

    Reported by gwt.team.scottb on 2007-04-27 19:38:42

    • Status changed: NeedsInfo

    - _Attachment: [semi-code-gen-r977.patch](https://storage.googleapis.com/google-code-attachments/google-web-toolkit/issue-978/comment-5/semi-code-gen-r977.patch)_
  7. dankurka commented on Jun 10, 2015

    @dankurka
    ContributorAuthor
    Makes sense since "if(a)" is incomplete but in "if(a);" the semi-colon is a valid
    empty statement.
    
    Sounds like we will need to wait for "if(a)" to either be reduced to "a" (if there
    are side-effects), or be (dead-code) eliminated.
    
    

    Reported by fredsa on 2007-04-27 20:36:23

  8. dankurka commented on Jun 10, 2015

    @dankurka
    ContributorAuthor
    One more:
    
    7) Replace semi-colon after "break" statements with newline
    

    Reported by fredsa on 2007-04-27 20:37:22

  9. dankurka commented on Jun 10, 2015

    @dankurka
    ContributorAuthor
    Unscheduling this for 1.4 since it's not as simple as we thought.
    

    Reported by gwt.team.scottb on 2007-04-28 16:48:30

    • Labels removed: Milestone-1_4_RC
  10. dankurka commented on Jun 10, 2015

    @dankurka
    ContributorAuthor
    sgross has a pending patch for the remainder of these (except for #2, which will
    become a new issue)
    
    

    Reported by scottb+legacy@google.com on 2008-02-07 20:18:25

    • Status changed: ReviewPending
    • Labels added: Milestone-1_5_RC
  11. dankurka commented on Jun 10, 2015

    @dankurka
    ContributorAuthor
    Committed sgross patch as r1805.  Opened issue #2073 for suggestion #2 which is not
    yet implemented.
    
    

    Reported by scottb+legacy@google.com on 2008-02-07 21:24:30

    • Status changed: FixedNotReleased
    • Labels added: ReviewBy-scottb
  12. dankurka commented on Jun 10, 2015

    @dankurka
    ContributorAuthor
    1_5_RC has been released.
    

    Reported by scottb+legacy@google.com on 2008-08-14 02:24:14

    • Status changed: Fixed
  13. dankurka commented on Jun 10, 2015

    @dankurka
    ContributorAuthor

    Reported by rjrjr@google.com on 2011-02-09 00:18:07

    • Labels added: Milestone-1_5-RC
    • Labels removed: Milestone-1_5_RC
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions