Skip to content

Commit 9215d97

Browse files
More simplification/refactoring.
1 parent 0a8443d commit 9215d97

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

background_scripts/completion.coffee

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -205,12 +205,12 @@ class DomainCompleter
205205
chrome.history.onVisitRemoved.addListener(@onVisitRemoved.bind(this))
206206
onComplete()
207207

208-
# We want each key in our domains hash to point to the most recent History entry for that domain.
209208
onPageVisited: (newPage) ->
210209
domain = @parseDomain(newPage.url)
211210
if domain
212211
@domains[domain] ||= { entry: newPage, referenceCount: 0 }
213212
slot = @domains[domain]
213+
# We want each entry in our domains hash to point to the most recent History entry for that domain.
214214
slot.entry = newPage if slot.entry.lastVisitTime < newPage.lastVisitTime
215215
slot.referenceCount += 1
216216

@@ -220,12 +220,8 @@ class DomainCompleter
220220
else
221221
toRemove.urls.forEach (url) =>
222222
domain = @parseDomain(url)
223-
if domain
224-
previousEntry = @domains[domain]
225-
if previousEntry
226-
previousEntry.referenceCount -= 1
227-
if previousEntry.referenceCount == 0
228-
delete @domains[domain]
223+
if domain and @domains[domain] and ( @domains[domain].referenceCount -= 1 ) == 0
224+
delete @domains[domain]
229225

230226
parseDomain: (url) -> url.split("/")[2] || ""
231227

0 commit comments

Comments
 (0)