aboutsummaryrefslogtreecommitdiffstats
path: root/src/js/static-net-filtering.js
diff options
context:
space:
mode:
authorgorhill <rhill@raymondhill.net>2015-02-07 23:42:07 -0500
committergorhill <rhill@raymondhill.net>2015-02-07 23:42:07 -0500
commitd9244b24c915ac849c5c3225e2f31e2a646d7de5 (patch)
treef344ddaa309bcdde4fbb59cddbf70f73752e2e6b /src/js/static-net-filtering.js
parentada85ca75eb16a93043b3f3a5a506a1f32042041 (diff)
downloaduBlock-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.js19
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));