Skip to content

Commit

Permalink
Precompute radiansBetweenAnnotations to reduce redundant calculations
Browse files Browse the repository at this point in the history
  • Loading branch information
vospennikov committed Oct 1, 2023
1 parent b402fb3 commit e97a35f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion Sources/ClusterMap/Public/Core/ClusterManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -263,9 +263,9 @@ private extension ClusterManager {
let hash = Dictionary(grouping: annotations) { $0.coordinate }
dispatchQueue.async(flags: .barrier) {
for value in hash.values where value.count > 1 {
let radiansBetweenAnnotations = (.pi * 2) / Double(value.count)
for (index, annotation) in value.enumerated() {
if var element = self.tree.remove(annotation) {
let radiansBetweenAnnotations = (.pi * 2) / Double(value.count)
let bearing = radiansBetweenAnnotations * Double(index)
element.coordinate = annotation.coordinate.coordinate(
onBearingInRadians: bearing,
Expand Down

0 comments on commit e97a35f

Please sign in to comment.