fasttime / JScrewIt

Write any JavaScript with six characters: ! ( ) + [ ]
https://jscrew.it
ISC License
161 stars 13 forks source link

Comma #15

Closed 837951602 closed 4 years ago

837951602 commented 7 years ago
  1. [Said]Array slice on the two(or more if the middle part has exactly 1 char) adjacent chars
  2. JScrewIt.encode('"0,00,0"',{features:['FILL','NO_IE_SRC']}).length = 766 JScrewIt.encode('[0].concat(0)+[0].concat(0)',{features:['FILL','NO_IE_SRC']}).length = 763
  3. In output.txt 391 | 1 | FILL, IE_SRC but when I run in it's 394. [Update]Ok I know that's because WITHOUT +[] ITS 391
fasttime commented 4 years ago

This kind of optimization has been removed in JScrewIt 2.17.0 because it doesn't improve encoding length in the current versions of any engines. The old concat bridge optimization was added to JScrewIt before a generic optimizer framework existed, and so it suffered from some design complications that would make it impossible for me to improve the existing implementation without rewriting the code from scratch.

Anyway, a new comma optimizer produces much better results in all new engines:

JScrewIt.encode('[0].concat(0)+[0].concat(0)', { features: 'COMPACT' }).length // 661
JScrewIt.encode('"0,00,0"', { features: 'COMPACT' }).length                    // 453

That is here [].flat.call("00")+[].flat.call("00") (or [].slice.call("00")+[].slice.call("00") if flat is not available).