mirror of
https://github.com/SukkaW/Surge.git
synced 2026-01-29 01:51:52 +08:00
Perf: many changes
- Hoist process hosts line callback - Reduce dp hosts file size - Reduce domain sort
This commit is contained in:
@@ -42,7 +42,15 @@ export const sortDomains = (inputs: string[], gorhill: PublicSuffixList) => {
|
||||
|
||||
const sorter = (a: string, b: string) => {
|
||||
if (a === b) return 0;
|
||||
return compare(domains.get(a)!, domains.get(b)!) || compare(a, b);
|
||||
|
||||
const $a = domains.get(a)!;
|
||||
const $b = domains.get(b)!;
|
||||
|
||||
// avoid compare same thing twice
|
||||
if (a === $a && b === $b) {
|
||||
return compare(a, b);
|
||||
}
|
||||
return compare($a, $b) || compare(a, b);
|
||||
};
|
||||
|
||||
return inputs.sort(sorter);
|
||||
|
||||
Reference in New Issue
Block a user