Skip to content

Commit ee4c673

Browse files
committed
perf: revert localeCompare remove
1 parent b0a795e commit ee4c673

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/core/tree.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ export interface TreeNodeOptions extends ResolvedOptions {
1212
treeNodeOptions?: TreeNodeValueOptions
1313
}
1414

15-
const stringCompare = new Intl.Collator('en', {}).compare
16-
1715
export class TreeNode {
1816
/**
1917
* value of the node
@@ -149,7 +147,9 @@ export class TreeNode {
149147
* @internal
150148
*/
151149
static compare(a: TreeNode, b: TreeNode): number {
152-
return stringCompare(a.path, b.path)
150+
// for this case, ASCII, short list, it's better than Internation Collator
151+
// https://stackoverflow.com/questions/77246375/why-localecompare-can-be-faster-than-collator-compare
152+
return a.path.localeCompare(b.path, 'en')
153153
}
154154

155155
/**

0 commit comments

Comments
 (0)