diff options
| author | Stephen Blott | 2016-03-18 08:46:50 +0000 | 
|---|---|---|
| committer | Stephen Blott | 2016-03-18 08:46:50 +0000 | 
| commit | 7a0f53a8dceb8ffb4f1080e84f1d875a4fa20b78 (patch) | |
| tree | 18c4411a39db5e8a6fed21b83540775c125868db /background_scripts/main.coffee | |
| parent | 009967b9ba7b7a14b9773f7ba18b8d9f5c85c747 (diff) | |
| download | vimium-7a0f53a8dceb8ffb4f1080e84f1d875a4fa20b78.tar.bz2 | |
Reduce complexity for initialising the top frame.
In #2053, I omitted to notice that the top-frame (vomnibar)
initialisation sequence also generates O(n^2) messages.
This makes that sequence O(n).
Diffstat (limited to 'background_scripts/main.coffee')
| -rw-r--r-- | background_scripts/main.coffee | 7 | 
1 files changed, 6 insertions, 1 deletions
| diff --git a/background_scripts/main.coffee b/background_scripts/main.coffee index 5270ef02..4a982594 100644 --- a/background_scripts/main.coffee +++ b/background_scripts/main.coffee @@ -21,6 +21,7 @@ chrome.runtime.onInstalled.addListener ({ reason }) ->  currentVersion = Utils.getCurrentVersion()  frameIdsForTab = {}  root.urlForTab = {} +topFramePortForTab = {}  # This is exported for use by "marks.coffee".  root.tabLoadedHandlers = {} # tabId -> function() @@ -324,6 +325,7 @@ openOptionsPageInNewTab = ->  Frames =    onConnect: (sender, port) ->      [tabId, frameId] = [sender.tab.id, sender.frameId] +    topFramePortForTab[tabId] = port if frameId == 0      frameIdsForTab[tabId] ?= []      frameIdsForTab[tabId].push frameId unless frameId in frameIdsForTab[tabId]      port.postMessage handler: "registerFrameId", chromeFrameId: frameId @@ -364,6 +366,9 @@ Frames =        tabLoadedHandlers[tabId]?()        delete tabLoadedHandlers[tabId] +  initializeTopFrameUIComponents: ({tabId}) -> +    topFramePortForTab[tabId].postMessage handler: "initializeTopFrameUIComponents" +  handleFrameFocused = (request, sender) ->    [tabId, frameId] = [sender.tab.id, sender.frameId]    frameIdsForTab[tabId] ?= [] @@ -416,7 +421,7 @@ chrome.storage.local.remove "findModeRawQueryListIncognito"  # there are no remaining incognito-mode windows.  Since the common case is that there are none to begin with,  # we first check whether the key is set at all.  chrome.tabs.onRemoved.addListener (tabId) -> -  delete cache[tabId] for cache in [frameIdsForTab, urlForTab] +  delete cache[tabId] for cache in [frameIdsForTab, urlForTab, topFramePortForTab]    chrome.storage.local.get "findModeRawQueryListIncognito", (items) ->      if items.findModeRawQueryListIncognito        chrome.windows.getAll null, (windows) -> | 
