closure-compiler icon indicating copy to clipboard operation
closure-compiler copied to clipboard

Replace array-join by native string concats

Open infusion opened this issue 4 years ago • 0 comments

Hello,

as closure compiler optimizes for a good gzip compression ratio and a trivial benchmark revealed a 28x performance increase on v8 and couple percent on Firefox by replacing

[a, b, c].join(" ")

with

a + " " + b + " " + c

I would propose to transform the array-join approach (which is much more readable, easier to type and often used in libraries) to a more verbose native string concat. This provokes a bigger uncompressed file, but generates nice repeated patterns for gzip.

Thanks Robert

infusion avatar Jun 25 '21 08:06 infusion