From 1ecc61bebf21db5ffe7b105e93d7b24a3cd43448 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Mon, 11 Jul 2016 13:51:08 -0700 Subject: [PATCH] :racehorse: Avoid building unnecessary scope chains --- src/scope-descriptor.coffee | 8 ++++++++ src/text-editor-registry.js | 4 ++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/scope-descriptor.coffee b/src/scope-descriptor.coffee index 89c13d13f..ca97a2a43 100644 --- a/src/scope-descriptor.coffee +++ b/src/scope-descriptor.coffee @@ -47,3 +47,11 @@ class ScopeDescriptor toString: -> @getScopeChain() + + isEqual: (other) -> + if @scopes.length isnt other.scopes.length + return false + for scope, i in @scopes + if scope isnt other.scopes[i] + return false + true diff --git a/src/text-editor-registry.js b/src/text-editor-registry.js index c0e5ac9ff..0742a8477 100644 --- a/src/text-editor-registry.js +++ b/src/text-editor-registry.js @@ -116,7 +116,7 @@ export default class TextEditorRegistry { this.subscriptions.add( this.config.onDidChange(settingKey, configOptions, ({newValue}) => { this.editorsWithMaintainedConfig.forEach(editor => { - if (editor.getRootScopeDescriptor().getScopeChain() === scopeChain) { + if (editor.getRootScopeDescriptor().isEqual(scopeDescriptor)) { editor[setterName](newValue) } }) @@ -129,7 +129,7 @@ export default class TextEditorRegistry { const softTabs = this.config.get('editor.softTabs', configOptions) this.editorsWithMaintainedConfig.forEach(editor => { - if (editor.getRootScopeDescriptor().getScopeChain() === scopeChain) { + if (editor.getRootScopeDescriptor().isEqual(scopeDescriptor)) { editor.setSoftTabs(shouldEditorUseSoftTabs(editor, tabType, softTabs)) } })