Skip to content

Commit

Permalink
Avoid using method_getTypedSelector_np as detecting support is a pain
Browse files Browse the repository at this point in the history
  • Loading branch information
hmelder committed Oct 14, 2024
1 parent 883b2f9 commit ca802fe
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions Source/NSKeyValueCoding+Caching.m
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
*/

#import <objc/runtime.h>
#import <objc/encoding.h>
#import <objc/slot.h>

#import "common.h" // for likely and unlikely
Expand All @@ -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
Expand Down Expand Up @@ -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];
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit ca802fe

Please sign in to comment.