Skip to content

Commit b988aad

Browse files
Copilotalexr00
andcommitted
Move CHECK_STATE_ORDER constant outside component to avoid recreating on every render
Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
1 parent df0b1c7 commit b988aad

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

webviews/components/merge.tsx

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -570,17 +570,19 @@ export const MergeSelect = React.forwardRef<HTMLSelectElement, MergeSelectProps>
570570
},
571571
);
572572

573+
// State order for sorting status checks: failure first, then pending, neutral, success, and unknown
574+
const CHECK_STATE_ORDER: Record<CheckState, number> = {
575+
[CheckState.Failure]: 0,
576+
[CheckState.Pending]: 1,
577+
[CheckState.Neutral]: 2,
578+
[CheckState.Success]: 3,
579+
[CheckState.Unknown]: 4,
580+
};
581+
573582
const StatusCheckDetails = ( { statuses }: { statuses: PullRequestCheckStatus[] }) => {
574583
// Sort statuses to group by state: failure first, then pending, neutral, and success
575584
const sortedStatuses = [...statuses].sort((a, b) => {
576-
const stateOrder: Record<CheckState, number> = {
577-
[CheckState.Failure]: 0,
578-
[CheckState.Pending]: 1,
579-
[CheckState.Neutral]: 2,
580-
[CheckState.Success]: 3,
581-
[CheckState.Unknown]: 4,
582-
};
583-
return stateOrder[a.state] - stateOrder[b.state];
585+
return CHECK_STATE_ORDER[a.state] - CHECK_STATE_ORDER[b.state];
584586
});
585587

586588
return (

0 commit comments

Comments
 (0)