xp-framework / compiler

Compiles future PHP to today's PHP.
19 stars 0 forks source link

Enclose blocks where PHP only allows expressions #96

Closed thekid closed 3 years ago

thekid commented 3 years ago

This not only allows fn() => { ... } but also match ($arg) { 200 => { ... }}. Depends on xp-framework/ast#17

thekid commented 3 years ago

Performance figures show now measurable change:

timmf@Surface ~/devel/xp/compiler [tags/v5.7.0^0]
$ xp test src/test/php/
# ...

♥: 489/494 run (5 skipped), 489 succeeded, 0 failed
Memory used: 8316.46 kB (8374.73 kB peak)
Time taken: 0.247 seconds

timmf@Surface ~/devel/xp/compiler [refactor/block-expressions]
$ xp test src/test/php/
# ...

♥: 493/498 run (5 skipped), 493 succeeded, 0 failed
Memory used: 8354.23 kB (8412.50 kB peak)
Time taken: 0.247 seconds