Skip to content

Commit 8b7f7a0

Browse files
Use toSorted instead of cloning and then sorting
1 parent a0c9265 commit 8b7f7a0

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

packages/apollo-shared/src/Checks/CDSCheck.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,10 @@ function getOriginalCodonLocation(
9999
index: number,
100100
): [number, number] | undefined {
101101
// Index 0 is the start codon, so reverse the CDS locations if strand is -1
102-
const sortedLocation: CDSLocation = structuredClone(cdsLocation)
103-
if (strand === -1) {
104-
sortedLocation.sort((a, b) => (a.min < b.min ? 1 : -1))
105-
} else {
106-
sortedLocation.sort((a, b) => (a.min < b.min ? -1 : 1))
107-
}
102+
const sortedLocation =
103+
strand === -1
104+
? cdsLocation.toSorted((a, b) => (a.min < b.min ? 1 : -1))
105+
: cdsLocation.toSorted((a, b) => (a.min < b.min ? -1 : 1))
108106
let i = 0
109107
let currentStart: number | undefined = undefined
110108
let currentEnd: number | undefined = undefined

0 commit comments

Comments
 (0)