mirror of
https://github.com/morluto/rea.git
synced 2026-11-12 01:41:21 +00:00
perf(comparison): reuse canonical sort keys (#990)
This commit is contained in:
1 parent
2cedde9f1c
commit
ebb065e2dc
2 files changed
+119
-9
No files matched your search
@@ -177,15 +177,19 @@ export const stringAndNameProjection = (
|
||||
};
|
||||
|
||||
export const sorted = (values: readonly unknown[]): readonly unknown[] =>
|
||||
[...values].sort((left, right) => {
|
||||
const leftJson = canonicalJson(left, "Function normalization");
|
||||
const rightJson = canonicalJson(right, "Function normalization");
|
||||
// Preserve existing collation while ordering distinct values within a tie.
|
||||
return (
|
||||
leftJson.localeCompare(rightJson) ||
|
||||
compareCodePoints(leftJson, rightJson)
|
||||
);
|
||||
});
|
||||
values
|
||||
.map((value) => ({
|
||||
value,
|
||||
json: canonicalJson(value, "Function normalization"),
|
||||
}))
|
||||
.sort((left, right) => {
|
||||
// Preserve existing collation while ordering distinct values within a tie.
|
||||
return (
|
||||
left.json.localeCompare(right.json) ||
|
||||
compareCodePoints(left.json, right.json)
|
||||
);
|
||||
})
|
||||
.map(({ value }) => value);
|
||||
|
||||
export const combineCoverage = <Item>(
|
||||
left: FunctionCollection<Item>,
|
||||
|
||||
Reference in new issue
Block a user