Skip to content

Commit

Permalink
fix(geojson): hot path optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
missinglink committed Sep 20, 2024
1 parent 5b5fd17 commit 590c589
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion geojson/loop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,5 @@ export const removeAdjacentDuplicateVertices = (ring: geojson.Position[], epsilo
* Returns true IFF ring contains duplicate vertices at any position.
*/
export const containsDuplicateVertices = (ring: geojson.Position[]): boolean => {
return ring.some((A, i) => ring.slice(i + 1).some((B) => position.equal(A, B)))
return new Set(ring.map((c) => `${c[0]}|${c[1]}`)).size !== ring.length
}

0 comments on commit 590c589

Please sign in to comment.