diff options
| author | Stephen Blott | 2012-11-11 16:52:36 +0000 |
|---|---|---|
| committer | Stephen Blott | 2012-11-11 16:52:36 +0000 |
| commit | 9215d975207a3eb07e01cbc202fa2ee3402d332c (patch) | |
| tree | 3e9091c0de97867851a0bf103eb7701fb5259ce2 /background_scripts/completion.coffee | |
| parent | 0a8443d30dde0b7ba914a742182a1900baae2836 (diff) | |
| download | vimium-9215d975207a3eb07e01cbc202fa2ee3402d332c.tar.bz2 | |
More simplification/refactoring.
Diffstat (limited to 'background_scripts/completion.coffee')
| -rw-r--r-- | background_scripts/completion.coffee | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/background_scripts/completion.coffee b/background_scripts/completion.coffee index 95c50baf..08c33430 100644 --- a/background_scripts/completion.coffee +++ b/background_scripts/completion.coffee @@ -205,12 +205,12 @@ class DomainCompleter chrome.history.onVisitRemoved.addListener(@onVisitRemoved.bind(this)) onComplete() - # We want each key in our domains hash to point to the most recent History entry for that domain. onPageVisited: (newPage) -> domain = @parseDomain(newPage.url) if domain @domains[domain] ||= { entry: newPage, referenceCount: 0 } slot = @domains[domain] + # We want each entry in our domains hash to point to the most recent History entry for that domain. slot.entry = newPage if slot.entry.lastVisitTime < newPage.lastVisitTime slot.referenceCount += 1 @@ -220,12 +220,8 @@ class DomainCompleter else toRemove.urls.forEach (url) => domain = @parseDomain(url) - if domain - previousEntry = @domains[domain] - if previousEntry - previousEntry.referenceCount -= 1 - if previousEntry.referenceCount == 0 - delete @domains[domain] + if domain and @domains[domain] and ( @domains[domain].referenceCount -= 1 ) == 0 + delete @domains[domain] parseDomain: (url) -> url.split("/")[2] || "" |
