From db6786a0d65fd292c1e8492fef67c8105809ccf9 Mon Sep 17 00:00:00 2001 From: SukkaW Date: Sun, 26 May 2024 04:17:02 +0800 Subject: [PATCH] Perf: make domain sorting faster --- Build/lib/stable-sort-domain.ts | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/Build/lib/stable-sort-domain.ts b/Build/lib/stable-sort-domain.ts index ee29379b..dc6f996a 100644 --- a/Build/lib/stable-sort-domain.ts +++ b/Build/lib/stable-sort-domain.ts @@ -3,15 +3,16 @@ import { sort } from './timsort'; export const compare = (a: string, b: string) => { if (a === b) return 0; - - const aLen = a.length; - const r = aLen - b.length; - if (r !== 0) return r; - - return a.localeCompare(b); + return (a.length - b.length) || a.localeCompare(b); }; -const tldtsOpt = { allowPrivateDomains: false, detectIp: false, validateHostname: false }; +const tldtsOpt = { + extractHostname: false, + allowPrivateDomains: false, + detectIp: false, + validateHostname: false, + mixedInputs: false +}; export const sortDomains = (inputs: string[]) => { const domainMap = new Map();