mirror of
https://github.com/SukkaW/Surge.git
synced 2025-12-15 02:30:37 +08:00
Chore: minor changes
This commit is contained in:
parent
eabac5bfce
commit
20edd90c9b
@ -18,7 +18,7 @@ const pool = new Worktank({
|
|||||||
warmup: true,
|
warmup: true,
|
||||||
autoterminate: 30000, // The interval of milliseconds at which to check if the pool can be automatically terminated, to free up resources, workers will be spawned up again if needed
|
autoterminate: 30000, // The interval of milliseconds at which to check if the pool can be automatically terminated, to free up resources, workers will be spawned up again if needed
|
||||||
env: {},
|
env: {},
|
||||||
methods: { // An object mapping function names to functions objects to serialize and deserialize into each worker thread, only functions that don't depend on their closure can be serialized
|
methods: {
|
||||||
// eslint-disable-next-line object-shorthand -- workertank
|
// eslint-disable-next-line object-shorthand -- workertank
|
||||||
getreversedCidr: async function (cidr: string[], importMetaUrl: string): Promise<string[]> {
|
getreversedCidr: async function (cidr: string[], importMetaUrl: string): Promise<string[]> {
|
||||||
// TODO: createRequire is a temporary workaround for https://github.com/nodejs/node/issues/51956
|
// TODO: createRequire is a temporary workaround for https://github.com/nodejs/node/issues/51956
|
||||||
|
|||||||
@ -603,20 +603,25 @@ export class HostnameSmolTrie<Meta = unknown> extends Triebase<Meta> {
|
|||||||
node[0] = deleteBit(node[0], START);
|
node[0] = deleteBit(node[0], START);
|
||||||
}
|
}
|
||||||
|
|
||||||
cleanUpEmptyNode(node);
|
cleanUpEmptyTrailNode(node);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function cleanUpEmptyNode(node: TrieNode<unknown>) {
|
function cleanUpEmptyTrailNode(node: TrieNode<unknown>) {
|
||||||
if (
|
if (
|
||||||
|
// the current node is not an "end node", a.k.a. not the start of a domain
|
||||||
missingBit(node[0], START)
|
missingBit(node[0], START)
|
||||||
&& node[2].size === 0
|
// also no leading "." (no subdomain)
|
||||||
&& missingBit(node[0], INCLUDE_ALL_SUBDOMAIN)
|
&& missingBit(node[0], INCLUDE_ALL_SUBDOMAIN)
|
||||||
|
// child is empty
|
||||||
|
&& node[2].size === 0
|
||||||
|
// has parent: we need to detele the cureent node from the parent
|
||||||
|
// we also need to recursively clean up the parent node
|
||||||
&& node[1]
|
&& node[1]
|
||||||
) {
|
) {
|
||||||
node[1][2].delete(node[3]);
|
node[1][2].delete(node[3]);
|
||||||
|
// finish of the current stack
|
||||||
cleanUpEmptyNode(node[1]);
|
return cleanUpEmptyTrailNode(node[1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user