From 0d676e25048eba0f0f786be3565018563ba3c25b Mon Sep 17 00:00:00 2001 From: Tanner Bennett Date: Thu, 22 Oct 2020 18:16:10 -0500 Subject: [PATCH] Add FLEX_DISABLE_CTORS, close #471 --- Classes/Utility/FLEXUtility.m | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/Classes/Utility/FLEXUtility.m b/Classes/Utility/FLEXUtility.m index 028ddcc949..e623684411 100644 --- a/Classes/Utility/FLEXUtility.m +++ b/Classes/Utility/FLEXUtility.m @@ -15,17 +15,21 @@ #import BOOL FLEXConstructorsShouldRun() { - static BOOL _FLEXConstructorsShouldRun_storage = YES; - - static dispatch_once_t onceToken; - dispatch_once(&onceToken, ^{ - NSString *key = @"FLEX_SKIP_INIT"; - if (getenv(key.UTF8String) || [NSUserDefaults.standardUserDefaults boolForKey:key]) { - _FLEXConstructorsShouldRun_storage = NO; - } - }); - - return _FLEXConstructorsShouldRun_storage; + #if FLEX_DISABLE_CTORS + return NO; + #else + static BOOL _FLEXConstructorsShouldRun_storage = YES; + + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + NSString *key = @"FLEX_SKIP_INIT"; + if (getenv(key.UTF8String) || [NSUserDefaults.standardUserDefaults boolForKey:key]) { + _FLEXConstructorsShouldRun_storage = NO; + } + }); + + return _FLEXConstructorsShouldRun_storage; + #endif } @implementation FLEXUtility