This commit is contained in:
gorhill 2017-03-20 15:54:41 -04:00
parent dde8598ab5
commit 2dcf7b7974
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2
1 changed files with 12 additions and 2 deletions

View File

@ -978,6 +978,12 @@ var FilterHostnameDict = function() {
this.dict = new Set();
};
Object.defineProperty(FilterHostnameDict.prototype, 'size', {
get: function() {
return this.dict.size;
}
});
FilterHostnameDict.prototype.add = function(hn) {
if ( this.dict.has(hn) ) {
return false;
@ -986,6 +992,10 @@ FilterHostnameDict.prototype.add = function(hn) {
return true;
};
FilterHostnameDict.prototype.remove = function(hn) {
return this.dict.delete(hn);
};
FilterHostnameDict.prototype.match = function() {
// TODO: mind IP addresses
var pos,
@ -2097,8 +2107,8 @@ FilterContainer.prototype.removeBadFilters = function() {
continue;
}
if ( entry instanceof FilterHostnameDict ) {
entry.delete(fclass); // 'fclass' is hostname
if ( entry.dict.size === 0 ) {
entry.remove(fclass); // 'fclass' is hostname
if ( entry.size === 0 ) {
this.categories.delete(hash);
}
continue;