From b1912c89ac61bad0607840089df225c9d5497ee2 Mon Sep 17 00:00:00 2001 From: SukkaW Date: Sun, 23 Feb 2025 22:59:55 +0800 Subject: [PATCH] Perf: limit split when parsing hosts --- Build/lib/parse-filter/hosts.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Build/lib/parse-filter/hosts.ts b/Build/lib/parse-filter/hosts.ts index d551db7a..37ef044e 100644 --- a/Build/lib/parse-filter/hosts.ts +++ b/Build/lib/parse-filter/hosts.ts @@ -3,8 +3,10 @@ import { fetchAssets } from '../fetch-assets'; import { fastNormalizeDomainWithoutWww } from '../normalize-domain'; import { onBlackFound } from './shared'; +const rSpace = /\s+/; + function hostsLineCb(line: string, set: string[], includeAllSubDomain: boolean, meta: string) { - const _domain = line.split(/\s/)[1]?.trim(); + const _domain = line.split(rSpace, 3)[1]?.trim(); if (!_domain) { return; }