nodebox/opentype.js — pull request #74 by louisremi (2014-11-03 18:42:26+00:00)
Title: encode.CHARSTRING is often used on the exact same objects

Hi Frederik,

We're started to play around with opentype.js and see how we can use it in Prototypo!
First things first : I played with editor.html and opened a profiler. I noticed that the encoder was spending most of its time inside encode.CHARSTRING, and that it was often used on the exact same objects, producing the same result.
This patch is just a quick work-around to this problem but yields x2 speedup, according to my tests. Since you have a better knowledge of the code, you might be able to come up with a better solution.

I've also started to remove `.length` lookups from `for` loops declaration, as this is a clear, simple and effective perf optimization.

This bug is mostly here to get the discussion started.
Also: how can we start instrumenting and monitoring perf profiling?