From 51ade9f04399f836a4b09ce73cfdd52fc2d39dc1 Mon Sep 17 00:00:00 2001 From: gorhill Date: Tue, 21 Mar 2017 08:23:21 -0400 Subject: [PATCH] code review re. https://github.com/uBlockOrigin/uAssets/issues/192#issuecomment-285904675 --- src/js/static-net-filtering.js | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/src/js/static-net-filtering.js b/src/js/static-net-filtering.js index ab7a4a8e8..a33f370ba 100644 --- a/src/js/static-net-filtering.js +++ b/src/js/static-net-filtering.js @@ -2106,13 +2106,6 @@ FilterContainer.prototype.removeBadFilters = function() { if ( entry === undefined ) { continue; } - if ( entry instanceof FilterHostnameDict ) { - entry.remove(fclass); // 'fclass' is hostname - if ( entry.size === 0 ) { - this.categories.delete(hash); - } - continue; - } if ( entry instanceof FilterBucket ) { entry.remove(fclass, fdata); if ( entry.filters.length === 1 ) { @@ -2120,8 +2113,22 @@ FilterContainer.prototype.removeBadFilters = function() { } continue; } + if ( entry instanceof FilterHostnameDict ) { + entry.remove(fclass); // 'fclass' is hostname + if ( entry.size === 0 ) { + bucket.delete(token); + if ( bucket.size === 0 ) { + this.categories.delete(hash); + } + } + continue; + } if ( entry.fid === fclass && entry.toSelfie() === fdata ) { - this.categories.delete(hash); + bucket.delete(token); + if ( bucket.size === 0 ) { + this.categories.delete(hash); + } + continue; } } };