mirror of
https://github.com/SukkaW/Surge.git
synced 2025-12-12 09:10:35 +08:00
Perf: make build reject hosts faster
This commit is contained in:
parent
dcf565fb6b
commit
6ffff1093b
@ -141,8 +141,8 @@ const domainSuffixSet = new Set();
|
|||||||
});
|
});
|
||||||
for await (const line of rl3) {
|
for await (const line of rl3) {
|
||||||
const l = processLine(line);
|
const l = processLine(line);
|
||||||
if (l) {
|
if (l && l[0] === '.') {
|
||||||
domainSets.add(l);
|
domainSuffixSet.add(l.slice(1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -83,19 +83,9 @@ const createKeywordFilter = (keys) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
for (let idx = 0, len = keys.length; idx < len; idx++) {
|
||||||
* @param {string} key
|
const key = keys[idx];
|
||||||
*/
|
put(key, key.length);
|
||||||
const add = (key) => {
|
|
||||||
const len = key.length;
|
|
||||||
put(key, len);
|
|
||||||
build();
|
|
||||||
|
|
||||||
return true;
|
|
||||||
};
|
|
||||||
|
|
||||||
for (let idx = 0; idx < keys.length; idx++) {
|
|
||||||
add(keys[idx], false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
build();
|
build();
|
||||||
@ -106,10 +96,6 @@ const createKeywordFilter = (keys) => {
|
|||||||
*/
|
*/
|
||||||
const search = (text) => {
|
const search = (text) => {
|
||||||
let node = root;
|
let node = root;
|
||||||
/** @type {string[]} */
|
|
||||||
const fText = [];
|
|
||||||
/** @type {string[]} */
|
|
||||||
const oText = [];
|
|
||||||
|
|
||||||
for (let i = 0, textLen = text.length; i < textLen; i++) {
|
for (let i = 0, textLen = text.length; i < textLen; i++) {
|
||||||
// const key = text.charAt(i);
|
// const key = text.charAt(i);
|
||||||
@ -120,9 +106,6 @@ const createKeywordFilter = (keys) => {
|
|||||||
}
|
}
|
||||||
node = node?.children[key] || root;
|
node = node?.children[key] || root;
|
||||||
|
|
||||||
fText.push(key);
|
|
||||||
oText.push(key);
|
|
||||||
|
|
||||||
if (node.word) {
|
if (node.word) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user