this improves things just a bit

This commit is contained in:
gorhill 2014-07-02 23:33:26 -04:00
parent 7fd3054122
commit 646dde2f7c
1 changed files with 13 additions and 7 deletions

View File

@ -302,7 +302,7 @@ FilterContainer.prototype.add = function(s) {
// what it needs from it. Filters in that category are mostly // what it needs from it. Filters in that category are mostly
// `a[href^="..."]` kind of filters. // `a[href^="..."]` kind of filters.
// Content script side, the unsorted container of selectors could be used // Content script side, the unsorted container of selectors could be used
// in a querySelectorAll() to figure which rules apply (if any), or they // in a querySelector() to figure which rules apply (if any), or they
// could just all be injected undiscriminately (not good). // could just all be injected undiscriminately (not good).
if ( parsed.filterType === '#' ) { if ( parsed.filterType === '#' ) {
this.hideUnfiltered.push(parsed.suffix); this.hideUnfiltered.push(parsed.suffix);
@ -317,9 +317,18 @@ FilterContainer.prototype.add = function(s) {
/******************************************************************************/ /******************************************************************************/
FilterContainer.prototype.chunkify = function(selectors) { FilterContainer.prototype.chunkify = function(selectors) {
// Chunksize is a compromise between number of selectors per chunk (the
// number of selectors querySelector() will have to deal with), and the
// number of chunks (the number of times querySelector() will have to
// be called.)
// Benchmarking shows this is a hot spot performance-wise for "heavy"
// sites (like say, Sports Illustrated, good test case). Not clear what
// better can be done at this point, I doubt javascript-side code can beat
// querySelector().
var chunkSize = Math.max(selectors.length >>> 3, 8);
var chunkified = [], chunk; var chunkified = [], chunk;
for (;;) { for (;;) {
chunk = selectors.splice(0, 10); chunk = selectors.splice(0, chunkSize);
if ( chunk.length === 0 ) { if ( chunk.length === 0 ) {
break; break;
} }
@ -573,8 +582,8 @@ FilterContainer.prototype.retrieveGenericSelectors = function(tabHostname, reque
var r = { var r = {
hide: [], hide: [],
donthide: [], donthide: [],
hideUnfiltered: [], hideUnfiltered: this.hideUnfiltered,
donthideUnfiltered: [] donthideUnfiltered: this.donthideUnfiltered
}; };
var hash, bucket; var hash, bucket;
@ -595,9 +604,6 @@ FilterContainer.prototype.retrieveGenericSelectors = function(tabHostname, reque
} }
} }
r.hideUnfiltered = this.hideUnfiltered;
r.donthideUnfiltered = this.donthideUnfiltered;
//quickProfiler.stop(); //quickProfiler.stop();
//console.log( //console.log(