mirror of
https://github.com/gorhill/uBlock.git
synced 2024-11-23 19:03:02 +01:00
Store generic pattern string into bidi-trie buffer
This commit is contained in:
parent
92ad101557
commit
2b2af1f20d
@ -768,10 +768,16 @@ registerFilterClass(FilterPatternPlainX);
|
|||||||
|
|
||||||
const FilterPatternGeneric = class {
|
const FilterPatternGeneric = class {
|
||||||
static match(idata) {
|
static match(idata) {
|
||||||
const refs = filterRefs[filterData[idata+2]];
|
const refs = filterRefs[filterData[idata+4]];
|
||||||
if ( refs.$re === null ) {
|
if ( refs.$re === null ) {
|
||||||
refs.$re = new RegExp(
|
refs.$re = new RegExp(
|
||||||
restrFromGenericPattern(refs.s, filterData[idata+1])
|
restrFromGenericPattern(
|
||||||
|
bidiTrie.extractString(
|
||||||
|
filterData[idata+1],
|
||||||
|
filterData[idata+2]
|
||||||
|
),
|
||||||
|
filterData[idata+3]
|
||||||
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return refs.$re.test($requestURL);
|
return refs.$re.test($requestURL);
|
||||||
@ -788,13 +794,12 @@ const FilterPatternGeneric = class {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static fromCompiled(args) {
|
static fromCompiled(args) {
|
||||||
const idata = filterDataAllocLen(3);
|
const idata = filterDataAllocLen(5);
|
||||||
filterData[idata+0] = args[0]; // fid
|
filterData[idata+0] = args[0]; // fid
|
||||||
filterData[idata+1] = args[2]; // anchor
|
filterData[idata+1] = bidiTrie.storeString(args[1]); // i
|
||||||
filterData[idata+2] = filterRefAdd({
|
filterData[idata+2] = args[1].length; // n
|
||||||
s: args[1],
|
filterData[idata+3] = args[2]; // anchor
|
||||||
$re: null,
|
filterData[idata+4] = filterRefAdd({ $re: null });
|
||||||
});
|
|
||||||
return idata;
|
return idata;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -804,21 +809,22 @@ const FilterPatternGeneric = class {
|
|||||||
|
|
||||||
static logData(idata, details) {
|
static logData(idata, details) {
|
||||||
details.pattern.length = 0;
|
details.pattern.length = 0;
|
||||||
const anchor = filterData[idata+1];
|
const anchor = filterData[idata+3];
|
||||||
if ( (anchor & 0b100) !== 0 ) {
|
if ( (anchor & 0b100) !== 0 ) {
|
||||||
details.pattern.push('||');
|
details.pattern.push('||');
|
||||||
} else if ( (anchor & 0b010) !== 0 ) {
|
} else if ( (anchor & 0b010) !== 0 ) {
|
||||||
details.pattern.push('|');
|
details.pattern.push('|');
|
||||||
}
|
}
|
||||||
const refs = filterRefs[filterData[idata+2]];
|
const s = bidiTrie.extractString(
|
||||||
details.pattern.push(refs.s);
|
filterData[idata+1],
|
||||||
|
filterData[idata+2]
|
||||||
|
);
|
||||||
|
details.pattern.push(s);
|
||||||
if ( (anchor & 0b001) !== 0 ) {
|
if ( (anchor & 0b001) !== 0 ) {
|
||||||
details.pattern.push('|');
|
details.pattern.push('|');
|
||||||
}
|
}
|
||||||
details.regex.length = 0;
|
details.regex.length = 0;
|
||||||
details.regex.push(
|
details.regex.push(restrFromGenericPattern(s, anchor & ~0b100));
|
||||||
restrFromGenericPattern(refs.s, anchor & ~0b100)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user