This commit is contained in:
gorhill 2015-09-13 14:29:43 -04:00
parent 29c39550dd
commit 31f9cfe3de
2 changed files with 15 additions and 23 deletions

View File

@ -93,7 +93,7 @@ return {
// read-only // read-only
systemSettings: { systemSettings: {
compiledMagic: 'wzwgqiwgjhsh', compiledMagic: 'cxubjrcfrnrq',
selfieMagic: 'mnigwksyvgkv' selfieMagic: 'mnigwksyvgkv'
}, },

View File

@ -84,26 +84,24 @@ var histogram = function(label, buckets) {
// #A9AdsMiddleBoxTop // #A9AdsMiddleBoxTop
// .AD-POST // .AD-POST
var FilterPlain = function(s) { var FilterPlain = function() {
this.s = s;
}; };
FilterPlain.prototype.retrieve = function(s, out) { FilterPlain.prototype.retrieve = function(s, out) {
if ( s === this.s ) {
out.push(this.s); out.push(this.s);
}
}; };
FilterPlain.prototype.fid = '#'; FilterPlain.prototype.fid = '#';
FilterPlain.prototype.toSelfie = function() { FilterPlain.prototype.toSelfie = function() {
return this.s;
}; };
FilterPlain.fromSelfie = function(s) { FilterPlain.fromSelfie = function() {
return new FilterPlain(s); return filterPlain;
}; };
var filterPlain = new FilterPlain();
/******************************************************************************/ /******************************************************************************/
// Id- and class-based filters with extra selector stuff following. // Id- and class-based filters with extra selector stuff following.
@ -506,7 +504,6 @@ var makeHash = function(unhide, token, mask) {
var FilterContainer = function() { var FilterContainer = function() {
this.domainHashMask = (1 << 10) - 1; // 10 bits this.domainHashMask = (1 << 10) - 1; // 10 bits
this.genericHashMask = (1 << 15) - 1; // 15 bits
this.type0NoDomainHash = 'type0NoDomain'; this.type0NoDomainHash = 'type0NoDomain';
this.type1NoDomainHash = 'type1NoDomain'; this.type1NoDomainHash = 'type1NoDomain';
this.parser = new FilterParser(); this.parser = new FilterParser();
@ -666,8 +663,7 @@ FilterContainer.prototype.compileGenericSelector = function(parsed, out) {
if ( matches[1] === selector ) { if ( matches[1] === selector ) {
out.push( out.push(
'c\vlg\v' + 'c\vlg\v' +
makeHash(0, matches[1], this.genericHashMask) + '\v' + matches[1]
selector
); );
return; return;
} }
@ -675,7 +671,7 @@ FilterContainer.prototype.compileGenericSelector = function(parsed, out) {
if ( this.isValidSelector(selector) ) { if ( this.isValidSelector(selector) ) {
out.push( out.push(
'c\vlg+\v' + 'c\vlg+\v' +
makeHash(0, matches[1], this.genericHashMask) + '\v' + matches[1] + '\v' +
selector selector
); );
} }
@ -810,7 +806,7 @@ FilterContainer.prototype.fromCompiledContent = function(text, lineBeg, skip) {
// lg+ 2jx .Mpopup + #Mad > #MadZone // lg+ 2jx .Mpopup + #Mad > #MadZone
if ( fields[0] === 'lg' || fields[0] === 'lg+' ) { if ( fields[0] === 'lg' || fields[0] === 'lg+' ) {
filter = fields[0] === 'lg' ? filter = fields[0] === 'lg' ?
new FilterPlain(fields[2]) : filterPlain :
new FilterPlainMore(fields[2]); new FilterPlainMore(fields[2]);
bucket = this.lowGenericHide[fields[1]]; bucket = this.lowGenericHide[fields[1]];
if ( bucket === undefined ) { if ( bucket === undefined ) {
@ -1135,19 +1131,15 @@ FilterContainer.prototype.retrieveGenericSelectors = function(request) {
r.donthide = this.genericDonthide; r.donthide = this.genericDonthide;
} }
var hash, bucket;
var hashMask = this.genericHashMask;
var hideSelectors = r.hide; var hideSelectors = r.hide;
var selector, bucket;
var selectors = request.selectors; var selectors = request.selectors;
var i = selectors.length; var i = selectors.length;
var selector;
while ( i-- ) { while ( i-- ) {
selector = selectors[i]; if (
if ( !selector ) { (selector = selectors[i]) &&
continue; (bucket = this.lowGenericHide[selector])
} ) {
hash = makeHash(0, selector, hashMask);
if ( (bucket = this.lowGenericHide[hash]) ) {
bucket.retrieve(selector, hideSelectors); bucket.retrieve(selector, hideSelectors);
} }
} }