Chore: minor changes

This commit is contained in:
SukkaW 2025-03-02 19:58:37 +08:00
parent eabac5bfce
commit 20edd90c9b
2 changed files with 11 additions and 6 deletions

View File

@ -18,7 +18,7 @@ const pool = new Worktank({
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
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
getreversedCidr: async function (cidr: string[], importMetaUrl: string): Promise<string[]> {
// TODO: createRequire is a temporary workaround for https://github.com/nodejs/node/issues/51956

View File

@ -603,20 +603,25 @@ export class HostnameSmolTrie<Meta = unknown> extends Triebase<Meta> {
node[0] = deleteBit(node[0], START);
}
cleanUpEmptyNode(node);
cleanUpEmptyTrailNode(node);
};
}
function cleanUpEmptyNode(node: TrieNode<unknown>) {
function cleanUpEmptyTrailNode(node: TrieNode<unknown>) {
if (
// the current node is not an "end node", a.k.a. not the start of a domain
missingBit(node[0], START)
&& node[2].size === 0
// also no leading "." (no 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][2].delete(node[3]);
cleanUpEmptyNode(node[1]);
// finish of the current stack
return cleanUpEmptyTrailNode(node[1]);
}
}