mirror of
https://github.com/SukkaW/Surge.git
synced 2025-12-12 01:00:34 +08:00
Perf: make domain sorting faster
This commit is contained in:
parent
0d3148fb2a
commit
db6786a0d6
@ -3,15 +3,16 @@ import { sort } from './timsort';
|
|||||||
|
|
||||||
export const compare = (a: string, b: string) => {
|
export const compare = (a: string, b: string) => {
|
||||||
if (a === b) return 0;
|
if (a === b) return 0;
|
||||||
|
return (a.length - b.length) || a.localeCompare(b);
|
||||||
const aLen = a.length;
|
|
||||||
const r = aLen - b.length;
|
|
||||||
if (r !== 0) return r;
|
|
||||||
|
|
||||||
return 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[]) => {
|
export const sortDomains = (inputs: string[]) => {
|
||||||
const domainMap = new Map<string, string>();
|
const domainMap = new Map<string, string>();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user