🐎 Cache regexes in getRegexForProperty

This commit is contained in:
Antonio Scandurra 2016-02-18 14:12:44 +01:00
parent 3834066c75
commit 60b9cf1270

View File

@ -10,6 +10,7 @@ class LanguageMode
# editor - The {TextEditor} to associate with
constructor: (@editor, @config) ->
{@buffer} = @editor
@regexesByPattern = {}
destroy: ->
@ -328,7 +329,8 @@ class LanguageMode
getRegexForProperty: (scopeDescriptor, property) ->
if pattern = @config.get(property, scope: scopeDescriptor)
new OnigRegExp(pattern)
@regexesByPattern[pattern] ?= new OnigRegExp(pattern)
@regexesByPattern[pattern]
increaseIndentRegexForScopeDescriptor: (scopeDescriptor) ->
@getRegexForProperty(scopeDescriptor, 'editor.increaseIndentPattern')