summaryrefslogtreecommitdiffstats
path: root/src/js/biditrie.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 05:50:18 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 05:50:18 +0000
commit55a5d29a66503248916f249ad2a1d8b37cde5a03 (patch)
treea3beb6a90dd3bdaaf67ecb05d42152a494aff946 /src/js/biditrie.js
parentAdding upstream version 1.55.0+dfsg. (diff)
downloadublock-origin-upstream/1.57.0+dfsg.tar.xz
ublock-origin-upstream/1.57.0+dfsg.zip
Adding upstream version 1.57.0+dfsg.upstream/1.57.0+dfsgupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/js/biditrie.js')
-rw-r--r--src/js/biditrie.js31
1 files changed, 8 insertions, 23 deletions
diff --git a/src/js/biditrie.js b/src/js/biditrie.js
index d0f64ee..1329316 100644
--- a/src/js/biditrie.js
+++ b/src/js/biditrie.js
@@ -576,34 +576,19 @@ class BidiTrieContainer {
};
}
- serialize(encoder) {
- if ( encoder instanceof Object ) {
- return encoder.encode(
- this.buf32.buffer,
- this.buf32[CHAR1_SLOT]
- );
- }
- return Array.from(
- new Uint32Array(
- this.buf32.buffer,
- 0,
- this.buf32[CHAR1_SLOT] + 3 >>> 2
- )
+ toSelfie() {
+ return this.buf32.subarray(
+ 0,
+ this.buf32[CHAR1_SLOT] + 3 >>> 2
);
}
- unserialize(selfie, decoder) {
- const shouldDecode = typeof selfie === 'string';
- let byteLength = shouldDecode
- ? decoder.decodeSize(selfie)
- : selfie.length << 2;
+ fromSelfie(selfie) {
+ if ( selfie instanceof Uint32Array === false ) { return false; }
+ let byteLength = selfie.length << 2;
if ( byteLength === 0 ) { return false; }
this.reallocateBuf(byteLength);
- if ( shouldDecode ) {
- decoder.decode(selfie, this.buf8.buffer);
- } else {
- this.buf32.set(selfie);
- }
+ this.buf32.set(selfie);
return true;
}