ericmckean / traceur-compiler

Automatically exported from code.google.com/p/traceur-compiler
Apache License 2.0
0 stars 0 forks source link

Simplify output of default quasi #107

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
The deafult quasi

`hello ${ 42 }`

generates 

var $__0 = Object.freeze({ cooked: Object.freeze(["hello "]) }); 
traceur.runtime.defaultQuasi($__0, 42); 

We can simplify this a lot for the default quasi and just generate:

"hello " + (42) + ""

Once we have one string we can skip empty strings. For example

`${1}${2}${3}`

could naïvely be generated as

"" + (1) + "" + (2) + "" + (3) + ""

but once we have on string we can skip future empty string... resulting in

"" + (1) + (2) + (3)

we can also optimize away the parentheses

Original issue reported on code.google.com by arv@chromium.org on 25 Jun 2012 at 10:54

GoogleCodeExporter commented 9 years ago
https://code.google.com/p/traceur-compiler/source/detail?r=79870df

Original comment by arv@chromium.org on 28 Jun 2012 at 4:45