zedapp/zed — pull request #168 by robru (2014-04-02 08:12:28+00:00)
Title: Performance enhancements for getModeForSession.

Two changes here:

* Check if the first line of the file really starts with `#!`, and if not, don't bother looking for the shebang. This saves a lot of checking for a lot of modes for files that don't even have a shebang.

* Make the extension checker stop checking after a matching extension is found. While I didn't profile this formally, you can plainly see the performance improvement here because I cut out: two variable assignments, a call to `indexOf`, a string concatenation, two subtractions, and an entire comparison. And I'm about 99% certain that the new code is functionally identical, unless I've gone loopy today.