aboutsummaryrefslogtreecommitdiffstats
path: root/background_scripts/completion.coffee
diff options
context:
space:
mode:
authorStephen Blott2012-11-11 16:52:36 +0000
committerStephen Blott2012-11-11 16:52:36 +0000
commit9215d975207a3eb07e01cbc202fa2ee3402d332c (patch)
tree3e9091c0de97867851a0bf103eb7701fb5259ce2 /background_scripts/completion.coffee
parent0a8443d30dde0b7ba914a742182a1900baae2836 (diff)
downloadvimium-9215d975207a3eb07e01cbc202fa2ee3402d332c.tar.bz2
More simplification/refactoring.
Diffstat (limited to 'background_scripts/completion.coffee')
-rw-r--r--background_scripts/completion.coffee10
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] || ""