diff options
author | gorhill <rhill@raymondhill.net> | 2015-02-07 23:42:07 -0500 |
---|---|---|
committer | gorhill <rhill@raymondhill.net> | 2015-02-07 23:42:07 -0500 |
commit | d9244b24c915ac849c5c3225e2f31e2a646d7de5 (patch) | |
tree | f344ddaa309bcdde4fbb59cddbf70f73752e2e6b /src/js/static-net-filtering.js | |
parent | ada85ca75eb16a93043b3f3a5a506a1f32042041 (diff) | |
download | uBlock-d9244b24c915ac849c5c3225e2f31e2a646d7de5.zip uBlock-d9244b24c915ac849c5c3225e2f31e2a646d7de5.tar.gz uBlock-d9244b24c915ac849c5c3225e2f31e2a646d7de5.tar.bz2 |
#723: code review pre-compute bit array
Diffstat (limited to 'src/js/static-net-filtering.js')
-rw-r--r-- | src/js/static-net-filtering.js | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/src/js/static-net-filtering.js b/src/js/static-net-filtering.js index c2d99e1..1268b76 100644 --- a/src/js/static-net-filtering.js +++ b/src/js/static-net-filtering.js @@ -70,6 +70,16 @@ var typeNameToTypeValue = { }; var typeOtherValue = typeNameToTypeValue.other; +// All network request types to bitmap +// bring origin to 0 (from 4 -- see typeNameToTypeValue) +// add 2 = number of left shift to use +// left-shift 1 by the above-calculated value +// subtract 4 to set all type bits, *except* for 2 lsb + +// https://github.com/gorhill/uBlock/issues/723 +// The 2 lsb *must* be zeroed +var allNetRequestTypesBitmap = (1 << (typeOtherValue >>> 4) + 2) - 4; + const BlockAnyTypeAnyParty = BlockAction | AnyType | AnyParty; const BlockAnyType = BlockAction | AnyType; const BlockAnyParty = BlockAction | AnyParty; @@ -1384,14 +1394,7 @@ FilterParser.prototype.parseOptType = function(raw, not) { // Negated type: set all valid network request type bits to 1 if ( this.types === 0 ) { - // bring origin to 0 (from 4 -- see typeNameToTypeValue) - // add 2 = number of left shift to use - // left-shift 1 by the above-calculated value - // subtract 4 to set all type bits, *except* for 2 lsb - - // https://github.com/gorhill/uBlock/issues/723 - // The 2 lsb *must* be zeroed - this.types = (1 << (typeNameToTypeValue.other >>> 4) + 2) - 4; + this.types = allNetRequestTypesBitmap; } this.types &= ~(1 << (type >>> 4)); |