batiste / pug-vdom

PUG template to HyperScript Virtual DOM
MIT License
18 stars 6 forks source link

each: only evaluate the expression once. #33

Closed albb0920 closed 5 years ago

albb0920 commented 5 years ago

Hi

When using the each loop, the expression part is evaluate upon each iteration. This could be problematic if the expression's output changes each time, or if the expression is expensive to compute.

This patch saves the expression's result in a temporary variable, just like the official implementation. https://github.com/pugjs/pug/blob/pug%402.0.3/packages/pug-code-gen/index.js#L731

Thank you!