+376
-207
lines changedFilter options
+376
-207
lines changed Original file line number Diff line number Diff line change
@@ -138,8 +138,8 @@ const µBlock = (( ) => { // jshint ignore:line
138
138
139
139
// Read-only
140
140
systemSettings: {
141
-
compiledMagic: 27, // Increase when compiled format changes
142
-
selfieMagic: 26, // Increase when selfie format changes
141
+
compiledMagic: 28, // Increase when compiled format changes
142
+
selfieMagic: 28, // Increase when selfie format changes
143
143
},
144
144
145
145
// https://github.com/uBlockOrigin/uBlock-issues/issues/759#issuecomment-546654501
Original file line number Diff line number Diff line change
@@ -407,6 +407,49 @@ const HNTrieContainer = class {
407
407
return true;
408
408
}
409
409
410
+
// The following *Hostname() methods can be used to store hostname strings
411
+
// outside the trie. This is useful to store/match hostnames which are
412
+
// not part of a collection, and yet still benefit from storing the strings
413
+
// into a trie container's character buffer.
414
+
// TODO: WASM version of matchesHostname()
415
+
416
+
storeHostname(hn) {
417
+
let n = hn.length;
418
+
if ( n > 255 ) {
419
+
hn = hn.slice(-255);
420
+
n = 255;
421
+
}
422
+
if ( (this.buf.length - this.buf32[CHAR1_SLOT]) < n ) {
423
+
this.growBuf(0, n);
424
+
}
425
+
const offset = this.buf32[CHAR1_SLOT];
426
+
this.buf32[CHAR1_SLOT] = offset + n;
427
+
const buf8 = this.buf;
428
+
for ( let i = 0; i < n; i++ ) {
429
+
buf8[offset+i] = hn.charCodeAt(i);
430
+
}
431
+
return offset - this.buf32[CHAR0_SLOT];
432
+
}
433
+
434
+
extractHostname(i, n) {
435
+
const textDecoder = new TextDecoder();
436
+
const offset = this.buf32[CHAR0_SLOT] + i;
437
+
return textDecoder.decode(this.buf.subarray(offset, offset + n));
438
+
}
439
+
440
+
matchesHostname(hn, i, n) {
441
+
this.setNeedle(hn);
442
+
const buf8 = this.buf;
443
+
const hr = buf8[255];
444
+
if ( n > hr ) { return false; }
445
+
const hl = hr - n;
446
+
const nl = this.buf32[CHAR0_SLOT] + i;
447
+
for ( let j = 0; j < n; j++ ) {
448
+
if ( buf8[nl+j] !== buf8[hl+j] ) { return false; }
449
+
}
450
+
return n === hr || hn.charCodeAt(hl-1) === 0x2E /* '.' */;
451
+
}
452
+
410
453
async enableWASM() {
411
454
if ( typeof WebAssembly !== 'object' ) { return false; }
412
455
if ( this.wasmMemory instanceof WebAssembly.Memory ) { return true; }
You can’t perform that action at this time.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4