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

dart2dart minifier ideas for the future #6074

Closed
DartBot opened this issue Oct 19, 2012 · 6 comments
Closed

dart2dart minifier ideas for the future #6074

DartBot opened this issue Oct 19, 2012 · 6 comments
Labels
closed-not-planned Closed as we don't intend to take action on the reported issue P3 A lower priority bug or feature request type-enhancement A request for a change that isn't a bug

Comments

@DartBot
Copy link

DartBot commented Oct 19, 2012

This issue was originally filed by smok@google.com


Quick summary of various ideas to improve dart2dart minifier efficiency.

  1. Remove import prefixes where possible and/or optimize import prefixes. Now we always import platform libraries with prefix, and that's at least +2 chars on each usage. Often imports are 2-3 char strings. However the size impact of that is small.
  2. Combine several declarations into one:
    "final a = 5; final b = 6;" => "final a=5,b=6";
  3. Inline methods that are used only once.
  4. Create short aliases for methods from platform libs that are often used, create short getters for fields. Example: "putIfAbsent", "containsKey". But this may affect performance.
  5. Reuse static fields and methods names. We can also try to reuse non-static member names, but that should be done carefully, we need to infer types for dynamic calls.

Smaller ideas:

  1. Stripped types still leave unnecessary whitespaces:
    "void foo(var a) {}" => "foo( a){}"
  2. Make 1-char constants for "null", "true", "false". (~3%)
  3. Strip type arguments, this is minor: "new A<B,C>();" => "new A();" (would save <1% of output)
  4. Change "final" to "var" where possible (<1%)
  5. Strip types in for expressions: "for(int a in list)" => "for(a in list)"
@kasperl
Copy link

kasperl commented Dec 14, 2012

Added this to the M3 milestone.

@anders-sandholm
Copy link
Contributor

Removed this from the M3 milestone.
Added this to the M4 milestone.

@larsbak
Copy link

larsbak commented May 28, 2013

Removed this from the M4 milestone.
Added this to the M5 milestone.

@kasperl
Copy link

kasperl commented May 31, 2013

Removed this from the M5 milestone.
Added this to the Later milestone.

@kasperl
Copy link

kasperl commented Jul 10, 2014

Removed this from the Later milestone.
Added Oldschool-Milestone-Later label.

@kasperl
Copy link

kasperl commented Aug 4, 2014

Removed Oldschool-Milestone-Later label.

@DartBot DartBot added Type-Enhancement P3 A lower priority bug or feature request labels Aug 4, 2014
@sethladd sethladd added the closed-not-planned Closed as we don't intend to take action on the reported issue label Jul 10, 2015
@kevmoo kevmoo added type-enhancement A request for a change that isn't a bug and removed triaged labels Mar 1, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed-not-planned Closed as we don't intend to take action on the reported issue P3 A lower priority bug or feature request type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

6 participants