mirror of
https://github.com/SukkaW/Surge.git
synced 2026-01-29 01:51:52 +08:00
Perf: repalce aho-corasick w/ regexp
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { invariant } from 'foxts/guard';
|
||||
import { createAhoCorasick as createKeywordFilter } from 'foxts/ahocorasick';
|
||||
import { createRetrieKeywordFilter as createKeywordFilter } from 'foxts/retrie';
|
||||
import { RuleOutput } from './base';
|
||||
import type { SingboxSourceFormat } from '../singbox';
|
||||
|
||||
@@ -17,7 +17,7 @@ export class DomainsetOutput extends RuleOutput<string[]> {
|
||||
private $singbox_domains_suffixes: string[] = ['this_ruleset_is_made_by_sukkaw.ruleset.skk.moe'];
|
||||
private $adguardhome: string[] = [];
|
||||
preprocess() {
|
||||
const kwfilter = createKeywordFilter(this.domainKeywords);
|
||||
const kwfilter = createKeywordFilter(Array.from(this.domainKeywords));
|
||||
|
||||
this.domainTrie.dumpWithoutDot((domain, subdomain) => {
|
||||
if (kwfilter(domain)) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { merge } from 'fast-cidr-tools';
|
||||
import type { Span } from '../../trace';
|
||||
import { createAhoCorasick as createKeywordFilter } from 'foxts/ahocorasick';
|
||||
import { createRetrieKeywordFilter as createKeywordFilter } from 'foxts/retrie';
|
||||
import { appendArrayInPlace } from '../append-array-in-place';
|
||||
import { appendSetElementsToArray } from 'foxts/append-set-elements-to-array';
|
||||
import type { SingboxSourceFormat } from '../singbox';
|
||||
@@ -17,7 +17,7 @@ export class RulesetOutput extends RuleOutput<Preprocessed> {
|
||||
}
|
||||
|
||||
protected preprocess() {
|
||||
const kwfilter = createKeywordFilter(this.domainKeywords);
|
||||
const kwfilter = createKeywordFilter(Array.from(this.domainKeywords));
|
||||
|
||||
const domains: string[] = [];
|
||||
const domainSuffixes: string[] = [];
|
||||
|
||||
Reference in New Issue
Block a user