From 98dc0b6f81b1acf5ab30dc376a9ea44e9ed3923b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Minh=20Nguy=E1=BB=85n?= Date: Fri, 1 May 2015 19:24:14 -0400 Subject: [PATCH] Avoid creating MGLMapboxEvents when Metrics is disabled Mapbox Metrics already has a bottleneck; might as well use it to avoid fetching data in the first place. --- platform/ios/MGLMapboxEvents.m | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/platform/ios/MGLMapboxEvents.m b/platform/ios/MGLMapboxEvents.m index be299daf9..36ed63d33 100644 --- a/platform/ios/MGLMapboxEvents.m +++ b/platform/ios/MGLMapboxEvents.m @@ -214,13 +214,14 @@ NSString *const MGLEventGestureRotateStart = @"Rotation"; } // Can be called from any thread. Called implicitly from any -// public class convenience methods. +// public class convenience methods. May return nil if this feature is disabled. // + (instancetype)sharedManager { static dispatch_once_t onceToken; static MGLMapboxEvents *_sharedManager; dispatch_once(&onceToken, ^{ - if ( ! NSProcessInfo.processInfo.mgl_isInterfaceBuilderDesignablesAgent) { + if ( ! NSProcessInfo.processInfo.mgl_isInterfaceBuilderDesignablesAgent && + [[NSUserDefaults standardUserDefaults] objectForKey:@"mapbox_metrics_disabled"] == nil) { void (^setupBlock)() = ^{ _sharedManager = [[self alloc] init]; }; @@ -331,12 +332,6 @@ NSString *const MGLEventGestureRotateStart = @"Rotation"; return; } - // Add Metrics Disabled App Wide Check - if ([[NSUserDefaults standardUserDefaults] objectForKey:@"mapbox_metrics_disabled"] != nil) { - [_eventQueue removeAllObjects]; - return; - } - // Metrics Collection Has Been Paused if (_paused) { return;