From ca802fecbf1108d04dc38fb766b77c94e1a520a2 Mon Sep 17 00:00:00 2001 From: hmelder Date: Tue, 10 Sep 2024 16:17:17 +0200 Subject: [PATCH] Avoid using method_getTypedSelector_np as detecting support is a pain --- Source/NSKeyValueCoding+Caching.m | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/Source/NSKeyValueCoding+Caching.m b/Source/NSKeyValueCoding+Caching.m index 8bf693e2f..5a7ac8a70 100644 --- a/Source/NSKeyValueCoding+Caching.m +++ b/Source/NSKeyValueCoding+Caching.m @@ -23,6 +23,7 @@ */ #import +#import #import #import "common.h" // for likely and unlikely @@ -33,14 +34,12 @@ #import "Foundation/NSInvocation.h" #import "NSKeyValueCoding+Caching.h" + struct _KVCCacheSlot { Class cls; - union - { - SEL selector; - const char *types; - }; + SEL selector; + const char *types; uintptr_t hash; // The slot version returned by objc_get_slot2. // Set to zero when this is caching an ivar lookup @@ -172,8 +171,7 @@ static id _fnname(struct _KVCCacheSlot *slot, id obj) \ NSInvocation *inv; NSMethodSignature *sig; size_t retSize; - - const char *types = sel_getType_np(slot->selector); + const char *types = slot->types; sig = [NSMethodSignature signatureWithObjCTypes:types]; inv = [NSInvocation invocationWithMethodSignature:sig]; @@ -325,7 +323,8 @@ static id _fnname(struct _KVCCacheSlot *slot, id obj) \ } slot.imp = method_getImplementation(method); - slot.selector = method_getTypedSelector_np(method); + slot.selector = sel; + slot.types = encoding; slot.version = version; // TODO: Move most commonly used types up the switch statement