marijnh/CodeMirror — pull request #1609 by aslushnikov (2013-06-13 15:51:48+00:00)
Title: Proof-of-concept: char dictionary in measureLineInner

Hi Marijnh,

I'm trying to adapt CodeMirror for displaying/editing minified js files, which usually contain couple of very long lines. Currently it takes far too long to initially render a line which consists of 75k characters. The vast majority of time is spent in `measureLineInner` method, which forces layout for many one-character spans.

One of the possible solutions would be a character metrics dictionary. The idea is to
construct a dictionary that would contain a metric for every `char` X `class` occurrence. This drastically reduces the amount of layouted nodes.

The downside is that the approach won't work in case of lineWraping option on, but speeding up a non-line-wrapping mode is a great achievement as well.

I attach a proof-of-concept patch that does the trick (in a dirty non-finished way) and which works for me in Chrome. The speedup is about 27 times: 75k file without highlighter gets opened in about 580ms instead of 16000ms.

What is your opinion about it?