Skip to content

Commit

Permalink
Perf: new timsort
Browse files Browse the repository at this point in the history
  • Loading branch information
SukkaW committed May 10, 2024
1 parent deb3688 commit 2fbb4a7
Show file tree
Hide file tree
Showing 4 changed files with 960 additions and 6 deletions.
8 changes: 4 additions & 4 deletions Build/lib/stable-sort-domain.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { PublicSuffixList } from '@gorhill/publicsuffixlist';
import { sort } from 'timsort';
import { sort } from './timsort';

const compare = (a: string, b: string) => {
if (a === b) return 0;
Expand Down Expand Up @@ -42,10 +42,10 @@ export const sortDomains = (inputs: string[], gorhill: PublicSuffixList) => {
const $a = domains.get(a);
const $b = domains.get(b);

if ($a && $b) {
return compare($a, $b) || compare(a, b);
if ($a == null || $b == null) {
return compare(a, b);
}
return compare(a, b);
return compare($a, $b) || compare(a, b);
};

sort(inputs, sorter);
Expand Down
Loading

0 comments on commit 2fbb4a7

Please sign in to comment.