Store the selector, not the type encoding, in slots.

main
theraven 15 years ago
parent bd48461fb9
commit 535ba87a8e

@ -31,8 +31,8 @@ struct objc_slot
* to the same object and sharing a cached slot then it may also improve * to the same object and sharing a cached slot then it may also improve
* cache hits. Profiling is probably required here. */ * cache hits. Profiling is probably required here. */
Class cachedFor; Class cachedFor;
/** The type encoding for the method identified by this slot. */ /** The (typed) selector for the method identified by this slot. */
const char *types; SEL selector;
/** The current version. This changes if the method changes or if a /** The current version. This changes if the method changes or if a
* subclass overrides this method, potentially invalidating this cache. */ * subclass overrides this method, potentially invalidating this cache. */
int version; int version;

@ -302,7 +302,7 @@ Method class_getInstanceMethod(Class aClass, SEL aSelector)
if (NULL == slot) { return NULL; } if (NULL == slot) { return NULL; }
// Now find the typed variant of the selector, with the correct types. // Now find the typed variant of the selector, with the correct types.
aSelector = sel_registerTypedName_np(sel_getName(aSelector), slot->types); aSelector = slot->selector;
// Then do the slow lookup to find the method. // Then do the slow lookup to find the method.
return class_getInstanceMethodNonrecursive(slot->owner, aSelector); return class_getInstanceMethodNonrecursive(slot->owner, aSelector);

@ -12,7 +12,7 @@ void objc_send_initialize(id object);
static id nil_method(id self, SEL _cmd) { return nil; } static id nil_method(id self, SEL _cmd) { return nil; }
static struct objc_slot nil_slot = { Nil, Nil, "", 1, (IMP)nil_method }; static struct objc_slot nil_slot = { Nil, Nil, 0, 1, (IMP)nil_method };
typedef struct objc_slot *Slot_t; typedef struct objc_slot *Slot_t;

@ -10,7 +10,7 @@ static inline struct objc_slot *new_slot_for_method_in_class(Method method,
{ {
struct objc_slot *slot = slot_pool_alloc(); struct objc_slot *slot = slot_pool_alloc();
slot->owner = class; slot->owner = class;
slot->types = method->types; slot->selector = method->selector;
slot->method = method->imp; slot->method = method->imp;
slot->version = 1; slot->version = 1;
return slot; return slot;

Loading…
Cancel
Save