mirror of
https://github.com/SukkaW/Surge.git
synced 2026-01-28 17:41:54 +08:00
Perf: preload/hoist more promises, make ts happy
This commit is contained in:
@@ -24,6 +24,7 @@ const BLACKLIST = [
|
||||
|
||||
export const getMicrosoftCdnRulesetPromise = createMemoizedPromise(async () => {
|
||||
const set = await traceAsync('fetch accelerated-domains.china.conf', async () => {
|
||||
// First trie is to find the microsoft domains that matches probe domains
|
||||
const trie = createTrie();
|
||||
for await (const line of await fetchRemoteTextByLine('https://raw.githubusercontent.com/felixonmars/dnsmasq-china-list/master/accelerated-domains.china.conf')) {
|
||||
if (line.startsWith('server=/') && line.endsWith('/114.114.114.114')) {
|
||||
@@ -34,6 +35,7 @@ export const getMicrosoftCdnRulesetPromise = createMemoizedPromise(async () => {
|
||||
return new Set(PROBE_DOMAINS.flatMap(domain => trie.find(domain, false)));
|
||||
});
|
||||
|
||||
// Second trie is to remove blacklisted domains
|
||||
const trie2 = createTrie(set);
|
||||
const black = BLACKLIST.flatMap(domain => trie2.find(domain, true));
|
||||
for (let i = 0, len = black.length; i < len; i++) {
|
||||
|
||||
Reference in New Issue
Block a user