瀏覽代碼

Chore: minor changes

SukkaW 1 年之前
父節點
當前提交
f0a3b3e915
共有 3 個文件被更改,包括 5 次插入10 次删除
  1. 1 1
      Build/lib/cache-filesystem.ts
  2. 2 2
      Build/lib/rules/base.ts
  3. 2 7
      Build/validate-domestic.ts

+ 1 - 1
Build/lib/cache-filesystem.ts

@@ -290,7 +290,7 @@ export class Cache<S = string> {
       // Most assets can be downloaded within 250ms. To avoid wasting bandwidth, we will wait for 500ms before downloading from the fallback URL.
       // Most assets can be downloaded within 250ms. To avoid wasting bandwidth, we will wait for 500ms before downloading from the fallback URL.
       if (index > 0) {
       if (index > 0) {
         try {
         try {
-          await sleepWithAbort(300 + (index + 1) * 10, controller.signal);
+          await sleepWithAbort(100 + (index + 1) * 10, controller.signal);
         } catch {
         } catch {
           console.log(picocolors.gray('[fetch cancelled early]'), picocolors.gray(url));
           console.log(picocolors.gray('[fetch cancelled early]'), picocolors.gray(url));
           throw new CustomAbortError();
           throw new CustomAbortError();

+ 2 - 2
Build/lib/rules/base.ts

@@ -1,6 +1,6 @@
 import { OUTPUT_CLASH_DIR, OUTPUT_MODULES_DIR, OUTPUT_SINGBOX_DIR, OUTPUT_SURGE_DIR } from '../../constants/dir';
 import { OUTPUT_CLASH_DIR, OUTPUT_MODULES_DIR, OUTPUT_SINGBOX_DIR, OUTPUT_SURGE_DIR } from '../../constants/dir';
 import type { Span } from '../../trace';
 import type { Span } from '../../trace';
-import { createTrie } from '../trie';
+import { HostnameSmolTrie } from '../trie';
 import stringify from 'json-stringify-pretty-compact';
 import stringify from 'json-stringify-pretty-compact';
 import path from 'node:path';
 import path from 'node:path';
 import { withBannerArray } from '../misc';
 import { withBannerArray } from '../misc';
@@ -12,7 +12,7 @@ import { readFileByLine } from '../fetch-text-by-line';
 import { asyncWriteToStream } from '../async-write-to-stream';
 import { asyncWriteToStream } from '../async-write-to-stream';
 
 
 export abstract class RuleOutput<TPreprocessed = unknown> {
 export abstract class RuleOutput<TPreprocessed = unknown> {
-  protected domainTrie = createTrie(null, true);
+  protected domainTrie = new HostnameSmolTrie(null);
   protected domainKeywords = new Set<string>();
   protected domainKeywords = new Set<string>();
   protected domainWildcard = new Set<string>();
   protected domainWildcard = new Set<string>();
   protected userAgent = new Set<string>();
   protected userAgent = new Set<string>();

+ 2 - 7
Build/validate-domestic.ts

@@ -1,19 +1,14 @@
 import { readFileByLine } from './lib/fetch-text-by-line';
 import { readFileByLine } from './lib/fetch-text-by-line';
 import { parse } from 'csv-parse/sync';
 import { parse } from 'csv-parse/sync';
-import { createTrie } from './lib/trie';
+import { HostnameSmolTrie } from './lib/trie';
 import path from 'node:path';
 import path from 'node:path';
 import { processLine } from './lib/process-line';
 import { processLine } from './lib/process-line';
 import { SOURCE_DIR } from './constants/dir';
 import { SOURCE_DIR } from './constants/dir';
 import { $fetch } from './lib/make-fetch-happen';
 import { $fetch } from './lib/make-fetch-happen';
 import { parseFelixDnsmasqFromResp } from './lib/parse-dnsmasq';
 import { parseFelixDnsmasqFromResp } from './lib/parse-dnsmasq';
 
 
-async function parseFelixDnsmasq(url: string): Promise<string[]> {
-  const resp = await $fetch(url);
-  return parseFelixDnsmasqFromResp(resp);
-}
-
 export async function parseDomesticList() {
 export async function parseDomesticList() {
-  const trie = createTrie(await parseFelixDnsmasq('https://raw.githubusercontent.com/felixonmars/dnsmasq-china-list/master/accelerated-domains.china.conf'));
+  const trie = new HostnameSmolTrie(await parseFelixDnsmasqFromResp(await $fetch('https://raw.githubusercontent.com/felixonmars/dnsmasq-china-list/master/accelerated-domains.china.conf')));
 
 
   const top5000 = new Set<string>();
   const top5000 = new Set<string>();