Fastest method for getting size of text range

My CodeMirror-blocks project has progressed to the point where I can show it off a bit (click the icon in the top-right corner of the code!), and where I can start polishing and optimizing.

One thing my app does a LOT during the animation is measure the exact size of every literal in the viewport. Currently I do this with markText and getBoundingClientRect, but all those markText calls and DOM creation eat up 30% of the computation time.

I’m wondering if there’s a faster way to measure a given text range, without having to mess with CM’s DOM and cause repaints. Any suggestions would be greatly appreciated!

You can call charCoords on the start and end and compute a rectangle from that.

Ah, of course! Thanks, @marijn!