Siorki / RegPack

Self-contained packer for size-constrained JS code
Other
299 stars 14 forks source link

[enhancement] with(c) #22

Open xem opened 9 years ago

xem commented 9 years ago

Sometimes, you can achieve a better compression by evaluating all the code with "with(c)". It saves 2 bytes everytime you call a context function

Ex:

c.fill() => fill()

Could it be added in RegPack?

Cheers

Siorki commented 9 years ago

Using with(...) can cause a serious performance hit and halve - or worst - your framerate. For this reason I shall keep it an option as is currently done for with(Math).

The expected gain would be 2n-7, n being the number of copies of "c.". 8-10 occurrences (average in benchmark group) mean around 10 bytes shaved off.

Prior investigation is needed to understand the interactions in having both with(c) and method hashing for c. I suspect possible shadowing between variables and method names that have been reduced to one or two letters.