marijnh/CodeMirror — pull request #1302 by JosephPecoraro (2013-03-01 21:16:15+00:00)
Title: Improve StreamStream performance on long lines - #1301

Fixes Issue #1301

StringStreams.prototype.column was always calculating the column offset for a
position by walking from index 0 in the string to the current start position.
That is factorial in performance and gets noticeably slower with long lines.

StringStreams only ever advance forward. So when determining the column we can
cache the value for a previous position on the line. Then the next time column
is called, we only need to update the cache for the small portion that the
Stream advanced. This way we only ever walk the stream once.