1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-11-07 03:12:33 +01:00

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',
pageURL: window.location.href,
selectors: lowGenericSelectors,
highGenerics: highGenerics === null
firstSurvey: highGenerics === null
},
retrieveHandler
);
// https://github.com/gorhill/uBlock/issues/452
// There is only one first..
retrieveHandler = otherRetrieveHandler;
retrieveHandler = nextRetrieveHandler;
} else {
otherRetrieveHandler(null);
nextRetrieveHandler(null);
}
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;
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();
//console.debug('µBlock> contextNodes = %o', contextNodes);
if ( selectors && selectors.highGenerics ) {
highGenerics = selectors.highGenerics;
}
if ( selectors && selectors.donthide.length ) {
processLowGenerics(selectors.donthide, nullArray);
}
var hideSelectors = [];
if ( selectors && selectors.hide.length ) {
processLowGenerics(selectors.hide, hideSelectors);

View File

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