Skip to content
This repository has been archived by the owner on May 11, 2021. It is now read-only.

Commit

Permalink
[refactoring] Use WeakSet where it's meant to be used
Browse files Browse the repository at this point in the history
  • Loading branch information
futpib committed Feb 1, 2015
1 parent 522dd1c commit 4085007
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 5 additions & 4 deletions src/lib/blocked-elements.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Cu.import "resource://gre/modules/NetUtil.jsm"
{ setTimeout, clearTimeout } = Cu.import "resource://gre/modules/Timer.jsm"

{
WeakSet
remove
isDead
superdomains
Expand Down Expand Up @@ -136,13 +137,13 @@ class BlockedElementHandler
i = tabs.getTabId tab
return unless i of @_tabIdToBlockedElements

restored = new Map
restored = new WeakSet
for elem in @_getAllByTabId i
if isDead elem
@_removeElemByTabId i, elem
else
@restore elem
restored.set elem, true
restored.add elem, true

return restored

Expand All @@ -151,15 +152,15 @@ class BlockedElementHandler
i = tabs.getTabId tab
return unless i of @_tabIdToBlockedElements

restored = new Map
restored = new WeakSet
for elem in @_getAllByTabId i
if isDead elem
@_removeElemByTabId i, elem
continue
if isSuperdomain(oHost, elem.ownerDocument.defaultView.location.host) \
and isSuperdomain(dHost, @getData elem, 'host')
@restore elem
restored.set elem
restored.add elem

return restored

Expand Down
2 changes: 1 addition & 1 deletion src/lib/ui/content-context-menu.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ exports.contentContextMenu = contentContextMenu =
event_command: do (blocked=blocked, ds=ds) -> ->
temp.addClosure (o, d, c) ->
return true if c._tabId == currentTabId \
and restored.get c._element
and restored.has c._element
temp.revokeClosure @ # FIXME may be revoked too soon
restored = blocked.restoreAllOnTab currentTabId

Expand Down

0 comments on commit 4085007

Please sign in to comment.