Performance enhancements for getModeForSession.
Check extensions longest-first but only if filename has a period.
Merge upstream master.
Merge pull request #168 from robru/extension-mode-performance

Performance enhancements for getModeForSession.