diff --git a/src/js/static-net-filtering.js b/src/js/static-net-filtering.js index 4fbc94f78..91cec9ff9 100644 --- a/src/js/static-net-filtering.js +++ b/src/js/static-net-filtering.js @@ -1286,7 +1286,7 @@ const FilterBucket = class { FilterPlainPrefix1.trieableStringFromArgs(fdata) ); } - if ( this.plainPrefix1Count === 7 ) { + if ( this.plainPrefix1Count === 3 ) { this.plainPrefix1Trie = FilterBucket.trieContainer.createOne(); this._transferTrieable( this.plainPrefix1Id, @@ -2867,6 +2867,23 @@ FilterContainer.prototype.benchmark = function(action) { /******************************************************************************/ +FilterContainer.prototype.bucketHistogram = function() { + const results = []; + for ( const [ bits, category ] of this.categories ) { + for ( const [ th, f ] of category ) { + if ( f instanceof FilterBucket === false ) { continue; } + const token = µBlock.urlTokenizer.stringFromTokenHash(th); + results.push({ bits, token, size: f.size, f }); + } + } + results.sort((a, b) => { + return b.size - a.size; + }); + console.log(results); +}; + +/******************************************************************************/ + return new FilterContainer(); /******************************************************************************/ diff --git a/src/js/utils.js b/src/js/utils.js index 88e51e361..b50de5fd1 100644 --- a/src/js/utils.js +++ b/src/js/utils.js @@ -75,6 +75,19 @@ return th; }, + stringFromTokenHash: function(th) { + if ( th === 0 ) { return ''; } + if ( th === 63 ) { return '*'; } + if ( th === 62 ) { return '.'; } + const chars = '0123456789%abcdefghijklmnopqrstuvwxyz'; + let s = ''; + while ( th > 0 ) { + s = `${chars.charAt((th & 0b111111)-1)}${s}`; + th /= 64; + } + return s; + }, + // https://github.com/chrisaljoudi/uBlock/issues/1118 // We limit to a maximum number of tokens.