bidiTrie is hardcoded

Thus no need to threat it as if it was a changing parameter.
This commit is contained in:
Raymond Hill 2025-03-20 12:03:17 -04:00
parent 7dba69dc48
commit 5b81369fc2
No known key found for this signature in database
GPG key ID: 25E1490B761470C2

View file

@ -3130,9 +3130,9 @@ const urlTokenizer = new (class {
}
// Tokenize on demand.
getTokens(encodeInto) {
getTokens() {
if ( this._tokenized ) { return this._tokens; }
let i = this._tokenize(encodeInto);
let i = this._tokenize();
this._tokens[i+0] = ANY_TOKEN_HASH;
this._tokens[i+1] = 0;
i += 2;
@ -3189,17 +3189,17 @@ const urlTokenizer = new (class {
// https://github.com/chrisaljoudi/uBlock/issues/1118
// We limit to a maximum number of tokens.
_tokenize(encodeInto) {
_tokenize() {
const tokens = this._tokens;
const url = this._urlOut;
const l = encodeInto.setHaystackLen(url.length);
const l = bidiTrie.setHaystackLen(url.length);
if ( l === 0 ) { return 0; }
let j = 0;
let hasq = -1;
mainLoop: {
const knownTokens = this.knownTokens;
const vtc = this._validTokenChars;
const charCodes = encodeInto.haystack;
const charCodes = bidiTrie.haystack;
let i = 0, n = 0, ti = 0, th = 0;
for (;;) {
for (;;) {
@ -4968,7 +4968,7 @@ StaticNetFilteringEngine.prototype.matchAndFetchModifiers = function(
results,
};
const tokenHashes = urlTokenizer.getTokens(bidiTrie);
const tokenHashes = urlTokenizer.getTokens();
let i = 0;
let th = 0, iunit = 0;
for (;;) {
@ -5158,7 +5158,7 @@ StaticNetFilteringEngine.prototype.realmMatchString = function(
}
// Pattern-based filters
else {
const tokenHashes = urlTokenizer.getTokens(bidiTrie);
const tokenHashes = urlTokenizer.getTokens();
let i = 0;
for (;;) {
tokenHash = tokenHashes[i];