1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-11-24 11:22:44 +01:00
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

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;