googlearchive / TemplateBinding

TemplateBinding Prolyfill
290 stars 61 forks source link

Compute .templateInstance lazily #138

Closed rafaelw closed 11 years ago

rafaelw commented 11 years ago

Right now it's done eagerly when the instance is created. This hits start-up cost. We can compute it when it's asked for

rafaelw commented 11 years ago

So the trouble with this is that polymer-expressions calls template.templateInstance do get the model of the parentScope. Also, looking at some of the benchmarks, it's not use templateInstance that was making SideTable.set show up as hot spot.

So instead, I changed the non-WeakMap impl of SideTable in TemplateBinding to do simple GET and PUTs. In the codereview app, this brings the expense of SideTable.set from about 11% down to about 2%.

https://github.com/Polymer/TemplateBinding/commit/1877b8faa7c6f9822b05be9736d15ee0fb76d372

I'm going to close this for now because it's no longer a clear win. Will revisit if it shows up again.