summaryrefslogtreecommitdiff
path: root/platform/macos/src
diff options
context:
space:
mode:
authorMinh Nguyễn <mxn@1ec5.org>2017-03-10 14:27:21 -0800
committerMinh Nguyễn <mxn@1ec5.org>2017-03-10 15:08:00 -0800
commitb74d7bfdb48d2a1a301945a02e41c422c0198456 (patch)
tree9e8c528787e75cc286d5cbb62cc2ae444c46c22d /platform/macos/src
parentffce46cae6cdc3a4b952a0aeca80b5d5f7304b6d (diff)
downloadqtlocation-mapboxgl-b74d7bfdb48d2a1a301945a02e41c422c0198456.tar.gz
[ios, macos] Corrected polyline equality
Now that annotation classes override -isEqual:, it’s no longer appropriate to rely on -isEqual: or -containsObject: to check for the preexistence of an annotation. Those methods become deep equality tests, which have worse performance. Checking for identity allows the developer to add a polyline and polygon with identical coordinates, title, etc. to the map. Implemented a missing -[MGLPolyline isEqual:]. Removed outdated comments about -annotationTagForAnnotation: being expensive.
Diffstat (limited to 'platform/macos/src')
-rw-r--r--platform/macos/src/MGLMapView.mm5
1 files changed, 2 insertions, 3 deletions
diff --git a/platform/macos/src/MGLMapView.mm b/platform/macos/src/MGLMapView.mm
index 68f36e044b..e72a755f51 100644
--- a/platform/macos/src/MGLMapView.mm
+++ b/platform/macos/src/MGLMapView.mm
@@ -1820,7 +1820,7 @@ public:
return annotationContext.annotation;
}
-/// Returns the annotation tag assigned to the given annotation. Relatively expensive.
+/// Returns the annotation tag assigned to the given annotation.
- (MGLAnnotationTag)annotationTagForAnnotation:(id <MGLAnnotation>)annotation {
if (!annotation || _annotationTagsByAnnotation.count(annotation) == 0) {
return MGLAnnotationTagNotFound;
@@ -1848,8 +1848,7 @@ public:
NSAssert([annotation conformsToProtocol:@protocol(MGLAnnotation)], @"Annotation does not conform to MGLAnnotation");
// adding the same annotation object twice is a no-op
- if ([self.annotations containsObject:annotation])
- {
+ if (_annotationTagsByAnnotation.count(annotation) != 0) {
continue;
}