codemirror/CodeMirror — pull request #2908 by MarcelGerber (2014-11-03 14:44:46+00:00)
Title: Function to get all tokens of a line

So in Brackets, we've [a function](https://github.com/adobe/brackets/blob/master/src/language/HTMLUtils.js#L509-L550) that runs `getTokenAt()` for every single token to find all modes in a particular file.
While this is OK on normal-length lines, it takes ages on very long lines. So, assuming you have a line with 10000 tokens, the [main while loop, and therefore `readToken`](https://github.com/codemirror/CodeMirror/blob/master/lib/codemirror.js#L4103-L4106) will run 50,005,000 times! (`t / 2 * (t + 1)`, where `t` is the token count).
With the function `getTokensOfLine`, newly introduced in this PR, the while loop will only run 10,000 times ;)

Hope you're interested in this function as well.