code review: no need to re-send generic exception filters every time

This commit is contained in:
gorhill 2015-03-13 17:05:28 -04:00
parent a0602fc343
commit 0bcde1666e
2 changed files with 20 additions and 17 deletions

View File

@ -110,15 +110,14 @@ var messager = vAPI.messaging.channel('contentscript-end.js');
what: 'retrieveGenericCosmeticSelectors', what: 'retrieveGenericCosmeticSelectors',
pageURL: window.location.href, pageURL: window.location.href,
selectors: lowGenericSelectors, selectors: lowGenericSelectors,
highGenerics: highGenerics === null firstSurvey: highGenerics === null
}, },
retrieveHandler retrieveHandler
); );
// https://github.com/gorhill/uBlock/issues/452 // https://github.com/gorhill/uBlock/issues/452
// There is only one first.. retrieveHandler = nextRetrieveHandler;
retrieveHandler = otherRetrieveHandler;
} else { } else {
otherRetrieveHandler(null); nextRetrieveHandler(null);
} }
lowGenericSelectors = []; lowGenericSelectors = [];
}; };
@ -148,21 +147,25 @@ var messager = vAPI.messaging.channel('contentscript-end.js');
} }
} }
} }
// Flush dead code from memory (does this work?) // Flush dead code from memory
firstRetrieveHandler = null; firstRetrieveHandler = null;
otherRetrieveHandler(response); // These are sent only once
if ( response ) {
if ( response.highGenerics ) {
highGenerics = response.highGenerics;
}
if ( response.donthide ) {
processLowGenerics(response.donthide, nullArray);
}
}
nextRetrieveHandler(response);
}; };
var otherRetrieveHandler = function(selectors) { var nextRetrieveHandler = function(selectors) {
//var tStart = timer.now(); //var tStart = timer.now();
//console.debug('µBlock> contextNodes = %o', contextNodes); //console.debug('µBlock> contextNodes = %o', contextNodes);
if ( selectors && selectors.highGenerics ) {
highGenerics = selectors.highGenerics;
}
if ( selectors && selectors.donthide.length ) {
processLowGenerics(selectors.donthide, nullArray);
}
var hideSelectors = []; var hideSelectors = [];
if ( selectors && selectors.hide.length ) { if ( selectors && selectors.hide.length ) {
processLowGenerics(selectors.hide, hideSelectors); processLowGenerics(selectors.hide, hideSelectors);

View File

@ -1055,12 +1055,10 @@ FilterContainer.prototype.retrieveGenericSelectors = function(request) {
//quickProfiler.start('FilterContainer.retrieve()'); //quickProfiler.start('FilterContainer.retrieve()');
var r = { var r = {
hide: [], hide: []
// https://github.com/gorhill/uBlock/issues/497
donthide: this.genericDonthide
}; };
if ( request.highGenerics ) { if ( request.firstSurvey ) {
r.highGenerics = { r.highGenerics = {
hideLow: this.highLowGenericHide, hideLow: this.highLowGenericHide,
hideLowCount: this.highLowGenericHideCount, hideLowCount: this.highLowGenericHideCount,
@ -1069,6 +1067,8 @@ FilterContainer.prototype.retrieveGenericSelectors = function(request) {
hideHigh: this.highHighGenericHide, hideHigh: this.highHighGenericHide,
hideHighCount: this.highHighGenericHideCount hideHighCount: this.highHighGenericHideCount
}; };
// https://github.com/gorhill/uBlock/issues/497
r.donthide = this.genericDonthide;
} }
var hash, bucket; var hash, bucket;