@@ -302,7 +302,7 @@ FilterContainer.prototype.add = function(s) {
302302 // what it needs from it. Filters in that category are mostly
303303 // `a[href^="..."]` kind of filters.
304304 // Content script side, the unsorted container of selectors could be used
305- // in a querySelectorAll () to figure which rules apply (if any), or they
305+ // in a querySelector () to figure which rules apply (if any), or they
306306 // could just all be injected undiscriminately (not good).
307307 if ( parsed . filterType === '#' ) {
308308 this . hideUnfiltered . push ( parsed . suffix ) ;
@@ -317,9 +317,18 @@ FilterContainer.prototype.add = function(s) {
317317/******************************************************************************/
318318
319319FilterContainer . prototype . chunkify = function ( selectors ) {
320+ // Chunksize is a compromise between number of selectors per chunk (the
321+ // number of selectors querySelector() will have to deal with), and the
322+ // number of chunks (the number of times querySelector() will have to
323+ // be called.)
324+ // Benchmarking shows this is a hot spot performance-wise for "heavy"
325+ // sites (like say, Sports Illustrated, good test case). Not clear what
326+ // better can be done at this point, I doubt javascript-side code can beat
327+ // querySelector().
328+ var chunkSize = Math . max ( selectors . length >>> 3 , 8 ) ;
320329 var chunkified = [ ] , chunk ;
321330 for ( ; ; ) {
322- chunk = selectors . splice ( 0 , 10 ) ;
331+ chunk = selectors . splice ( 0 , chunkSize ) ;
323332 if ( chunk . length === 0 ) {
324333 break ;
325334 }
@@ -573,8 +582,8 @@ FilterContainer.prototype.retrieveGenericSelectors = function(tabHostname, reque
573582 var r = {
574583 hide : [ ] ,
575584 donthide : [ ] ,
576- hideUnfiltered : [ ] ,
577- donthideUnfiltered : [ ]
585+ hideUnfiltered : this . hideUnfiltered ,
586+ donthideUnfiltered : this . donthideUnfiltered
578587 } ;
579588
580589 var hash , bucket ;
@@ -595,9 +604,6 @@ FilterContainer.prototype.retrieveGenericSelectors = function(tabHostname, reque
595604 }
596605 }
597606
598- r . hideUnfiltered = this . hideUnfiltered ;
599- r . donthideUnfiltered = this . donthideUnfiltered ;
600-
601607 //quickProfiler.stop();
602608
603609 //console.log(
0 commit comments