Perf: repalce String#localeCompare w/ simple ASCII-only compare

This commit is contained in:
SukkaW
2024-11-21 21:51:05 +08:00
parent 200da7a2be
commit c6f3a67711
5 changed files with 28 additions and 6 deletions

View File

@@ -3,10 +3,11 @@
// enough when sorting.
import * as tldts from 'tldts-experimental';
import { looseTldtsOpt } from '../constants/loose-tldts-opt';
import { fastStringCompare } from './misc';
export function compare(a: string, b: string) {
if (a === b) return 0;
return (a.length - b.length) || a.localeCompare(b);
return (a.length - b.length) || fastStringCompare(a, b);
}
export function buildParseDomainMap(inputs: string[]) {