Skip to content

Commit 0f575da

Browse files
Revert sort en performance critical areas
1 parent 3a3f9d4 commit 0f575da

3 files changed

Lines changed: 12 additions & 10 deletions

File tree

packages/lib-engine/src/processTargets/modifiers/scopeHandlers/SurroundingPairScopeHandler/SurroundingPairScopeHandler.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@ export class SurroundingPairScopeHandler extends BaseScopeHandler {
7373
this.scopeType.requireStrongContainment ?? false,
7474
),
7575
)
76-
.toSorted((a, b) => compareTargetScopes(direction, position, a, b));
76+
// oxlint-disable-next-line unicorn/no-array-sort
77+
.sort((a, b) => compareTargetScopes(direction, position, a, b));
7778
}
7879
}
7980

packages/lib-engine/src/processTargets/modifiers/scopeHandlers/TreeSitterScopeHandler/BaseTreeSitterScopeHandler.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ export abstract class BaseTreeSitterScopeHandler extends BaseScopeHandler {
4646
.matches(document, start, end)
4747
.map((match) => this.matchToScope(editor, match, isEveryScope))
4848
.filter((scope): scope is ExtendedTargetScope => scope != null)
49-
.toSorted((a, b) => compareTargetScopes(direction, position, a, b));
49+
// oxlint-disable-next-line unicorn/no-array-sort
50+
.sort((a, b) => compareTargetScopes(direction, position, a, b));
5051

5152
// Merge scopes that have the same domain into a single scope with multiple
5253
// targets

packages/lib-engine/src/util/allocateHats/getRankedTokens.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,21 +52,21 @@ export function getRankedTokens(
5252
return tokens;
5353
});
5454

55-
return moveForcedHatsToFront(forcedHatMap, tokens).map((token, index) => ({
55+
if (forcedHatMap != null) {
56+
moveForcedHatsToFront(forcedHatMap, tokens);
57+
}
58+
59+
return tokens.map((token, index) => ({
5660
token,
5761
rank: -index,
5862
}));
5963
}
6064

6165
function moveForcedHatsToFront(
62-
forcedHatMap: CompositeKeyMap<Token, TokenHat> | undefined,
66+
forcedHatMap: CompositeKeyMap<Token, TokenHat>,
6367
tokens: Token[],
64-
) {
65-
if (forcedHatMap == null) {
66-
return tokens;
67-
}
68-
69-
return tokens.toSorted((a, b) => {
68+
): void {
69+
tokens.sort((a, b) => {
7070
const aIsForced = forcedHatMap.has(a);
7171
const bIsForced = forcedHatMap.has(b);
7272
if (aIsForced && !bIsForced) {

0 commit comments

Comments
 (0)