fix regression in per-list filter counts (reported by @mapx-)

This commit is contained in:
Raymond Hill 2017-12-29 13:31:37 -05:00
parent 707d7708a1
commit 5c20182948
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2
4 changed files with 68 additions and 7 deletions

View File

@ -30,6 +30,8 @@
filterDB = new µb.staticExtFilteringEngine.HostnameBasedDB(),
pselectors = new Map(),
duplicates = new Set(),
acceptedCount = 0,
discardedCount = 0,
docRegister, loggerRegister;
var PSelectorHasTask = function(task) {
@ -224,6 +226,8 @@
filterDB.clear();
pselectors.clear();
duplicates.clear();
acceptedCount = 0;
discardedCount = 0;
};
api.freeze = function() {
@ -260,8 +264,12 @@
reader.select(1002);
while ( reader.next() ) {
acceptedCount += 1;
var fingerprint = reader.fingerprint();
if ( duplicates.has(fingerprint) ) { continue; }
if ( duplicates.has(fingerprint) ) {
discardedCount += 1;
continue;
}
duplicates.add(fingerprint);
var args = reader.args();
filterDB.add(args[1], {
@ -374,6 +382,19 @@
}
};
Object.defineProperties(api, {
acceptedCount: {
get: function() {
return acceptedCount;
}
},
discardedCount: {
get: function() {
return discardedCount;
}
}
});
return api;
})();

View File

@ -29,6 +29,8 @@
var µb = µBlock,
scriptletDB = new µb.staticExtFilteringEngine.HostnameBasedDB(),
duplicates = new Set(),
acceptedCount = 0,
discardedCount = 0,
scriptletCache = new µb.MRUCache(32),
exceptionsRegister = new Set(),
scriptletsRegister = new Map(),
@ -103,6 +105,8 @@
api.reset = function() {
scriptletDB.clear();
duplicates.clear();
acceptedCount = 0;
discardedCount = 0;
};
api.freeze = function() {
@ -154,8 +158,12 @@
reader.select(1001);
while ( reader.next() ) {
acceptedCount += 1;
var fingerprint = reader.fingerprint();
if ( duplicates.has(fingerprint) ) { continue; }
if ( duplicates.has(fingerprint) ) {
discardedCount += 1;
continue;
}
duplicates.add(fingerprint);
var args = reader.args();
if ( args.length < 4 ) { continue; }
@ -264,6 +272,19 @@
scriptletDB = new µb.staticExtFilteringEngine.HostnameBasedDB(selfie);
};
Object.defineProperties(api, {
acceptedCount: {
get: function() {
return acceptedCount;
}
},
discardedCount: {
get: function() {
return discardedCount;
}
}
});
return api;
})();

View File

@ -668,6 +668,23 @@
};
};
Object.defineProperties(api, {
acceptedCount: {
get: function() {
return µb.cosmeticFilteringEngine.acceptedCount +
µb.scriptletFilteringEngine.acceptedCount +
µb.htmlFilteringEngine.acceptedCount;
}
},
discardedCount: {
get: function() {
return µb.cosmeticFilteringEngine.discardedCount +
µb.scriptletFilteringEngine.discardedCount +
µb.htmlFilteringEngine.discardedCount;
}
}
});
api.fromSelfie = function(selfie) {
µb.cosmeticFilteringEngine.fromSelfie(selfie.cosmetic);
µb.scriptletFilteringEngine.fromSelfie(selfie.scriptlets);

View File

@ -562,14 +562,16 @@
var applyCompiledFilters = function(assetKey, compiled) {
var snfe = µb.staticNetFilteringEngine,
cfe = µb.cosmeticFilteringEngine,
acceptedCount = snfe.acceptedCount + cfe.acceptedCount,
discardedCount = snfe.discardedCount + cfe.discardedCount;
sxfe = µb.staticExtFilteringEngine,
acceptedCount = snfe.acceptedCount + sxfe.acceptedCount,
discardedCount = snfe.discardedCount + sxfe.discardedCount;
µb.applyCompiledFilters(compiled, assetKey === µb.userFiltersPath);
if ( µb.availableFilterLists.hasOwnProperty(assetKey) ) {
var entry = µb.availableFilterLists[assetKey];
entry.entryCount = snfe.acceptedCount + cfe.acceptedCount - acceptedCount;
entry.entryUsedCount = entry.entryCount - (snfe.discardedCount + cfe.discardedCount - discardedCount);
entry.entryCount = snfe.acceptedCount + sxfe.acceptedCount -
acceptedCount;
entry.entryUsedCount = entry.entryCount -
(snfe.discardedCount + sxfe.discardedCount - discardedCount);
}
loadedListKeys.push(assetKey);
};