From dbe8f199e9ddbd55a865ec2d4dfd250f5f411452 Mon Sep 17 00:00:00 2001 From: Frederik Seiffert Date: Thu, 27 Jun 2024 11:32:11 +0200 Subject: [PATCH] Fix build error with some compilers: initializer element is not a compile-time constant --- Source/NSKVOSupport.m | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Source/NSKVOSupport.m b/Source/NSKVOSupport.m index a32676cd7..c168a9372 100644 --- a/Source/NSKVOSupport.m +++ b/Source/NSKVOSupport.m @@ -320,12 +320,8 @@ - (bool)isEmpty if (keyLength > 0) { static const char *const sc_prefix = "keyPathsForValuesAffecting"; + static const size_t sc_prefixLength = 26; // strlen(sc_prefix) static const size_t sc_bufferSize = 128; - static const size_t sc_prefixLength = strlen(sc_prefix); // 26 - - const char *rawKey; - size_t rawKeyLength; - SEL sel; // max length of a key that can guaranteed fit in the char buffer, // even if UTF16->UTF8 conversion causes length to double, or a null @@ -333,6 +329,10 @@ - (bool)isEmpty static const size_t sc_safeKeyLength = (sc_bufferSize - sc_prefixLength) / 2 - 1; // 50 + const char *rawKey; + size_t rawKeyLength; + SEL sel; + rawKey = [key UTF8String]; rawKeyLength = strlen(rawKey); @@ -650,7 +650,7 @@ + (BOOL)automaticallyNotifiesObserversForKey:(NSString *)key if ([key length] > 0) { static const char *const sc_prefix = "automaticallyNotifiesObserversOf"; - static const size_t sc_prefixLength = strlen(sc_prefix); // 32 + static const size_t sc_prefixLength = 32; // strlen(sc_prefix) const char *rawKey = [key UTF8String]; size_t keyLength = strlen(rawKey); size_t bufferSize = sc_prefixLength + keyLength + 1;