batiste / pug-vdom

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

Improve locals exposure performance #27

Closed gryphonmyers closed 6 years ago

gryphonmyers commented 6 years ago

Previously, we were iterating over the entire locals object and evaluating each key. Performance testing indicated that this could get to be a significant bottleneck in larger apps with many keys in locals object.

With this commit, we instead attempt to temporarily add a getter to global scope. If there is a name conflict, we fall back to the eval method, but in most cases this will significantly improve performance.

batiste commented 6 years ago

Humm I have to say this is a bit complicated to grasp here...

gryphonmyers commented 6 years ago

Heh basically the change is to prevent the template function from having to eval() too much because that can get to be an expensive operation on a very large locals object.

gryphonmyers commented 6 years ago

@batiste Can I get a version bump?