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

Minor code reivew of 4430ec11e2

This commit is contained in:
Raymond Hill 2019-05-23 08:15:26 -04:00
parent 7b8c087fdd
commit 1f398134f9
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2

View File

@ -2910,65 +2910,56 @@ FilterContainer.prototype.realmMatchString = function(
const catBits11 = realmBits | typeBits | partyBits;
const bucket00 = exactType === 0
? this.categories.get(catBits00) || null
: null;
? this.categories.get(catBits00)
: undefined;
const bucket01 = exactType !== 0 || typeBits !== 0
? this.categories.get(catBits01) || null
: null;
? this.categories.get(catBits01)
: undefined;
const bucket10 = exactType === 0 && partyBits !== 0
? this.categories.get(catBits10) || null
: null;
? this.categories.get(catBits10)
: undefined;
const bucket11 = (exactType !== 0 || typeBits !== 0) && partyBits !== 0
? this.categories.get(catBits11) || null
: null;
? this.categories.get(catBits11)
: undefined;
if (
bucket00 === null && bucket01 === null &&
bucket10 === null && bucket11 === null
bucket00 === undefined && bucket01 === undefined &&
bucket10 === undefined && bucket11 === undefined
) {
return false;
}
let catBits = 0;
let catBits = 0, f;
// Pure hostname-based filters
let tokenHash = this.dotTokenHash;
let f;
if (
(bucket00 !== null) &&
(bucket00 !== undefined) &&
(f = bucket00.get(tokenHash)) !== undefined &&
(f.match() === true)
) {
catBits = catBits00;
} else if (
(bucket01 !== null) &&
(bucket01 !== undefined) &&
(f = bucket01.get(tokenHash)) !== undefined &&
(f.match() === true)
) {
catBits = catBits01;
} else if (
(bucket10 !== null) &&
(bucket10 !== undefined) &&
(f = bucket10.get(tokenHash)) !== undefined &&
(f.match() === true)
) {
catBits = catBits10;
} else if (
(bucket11 !== null) &&
(bucket11 !== undefined) &&
(f = bucket11.get(tokenHash)) !== undefined &&
(f.match() === true)
) {
catBits = catBits11;
} else {
f = undefined;
}
if ( f !== undefined ) {
this.catbitsRegister = catBits;
this.tokenRegister = tokenHash;
this.filterRegister = f;
return true;
}
// Pattern-based filters
else {
const url = this.urlRegister;
const tokenHashes = this.urlTokenizer.getTokens();
let i = 0, tokenBeg = 0;
@ -2977,7 +2968,7 @@ FilterContainer.prototype.realmMatchString = function(
if ( tokenHash === 0 ) { return false; }
tokenBeg = tokenHashes[i+1];
if (
(bucket00 !== null) &&
(bucket00 !== undefined) &&
(f = bucket00.get(tokenHash)) !== undefined &&
(f.match(url, tokenBeg) === true)
) {
@ -2985,7 +2976,7 @@ FilterContainer.prototype.realmMatchString = function(
break;
}
if (
(bucket01 !== null) &&
(bucket01 !== undefined) &&
(f = bucket01.get(tokenHash)) !== undefined &&
(f.match(url, tokenBeg) === true)
) {
@ -2993,7 +2984,7 @@ FilterContainer.prototype.realmMatchString = function(
break;
}
if (
(bucket10 !== null) &&
(bucket10 !== undefined) &&
(f = bucket10.get(tokenHash)) !== undefined &&
(f.match(url, tokenBeg) === true)
) {
@ -3001,7 +2992,7 @@ FilterContainer.prototype.realmMatchString = function(
break;
}
if (
(bucket11 !== null) &&
(bucket11 !== undefined) &&
(f = bucket11.get(tokenHash)) !== undefined &&
(f.match(url, tokenBeg) === true)
) {
@ -3010,6 +3001,8 @@ FilterContainer.prototype.realmMatchString = function(
}
i += 2;
}
}
this.catbitsRegister = catBits;
this.tokenRegister = tokenHash;
this.filterRegister = f;