Last active
January 3, 2019 06:56
objc_msgSend C version, from http://www.mulle-kybernetik.com/artikel/Optimization/opti-9.html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
id c_objc_msgSend( struct objc_class /* ahem */ *self, SEL _cmd, ...) | |
{ | |
struct objc_class *cls; | |
struct objc_cache *cache; | |
unsigned int hash; | |
struct objc_method *method; | |
unsigned int index; | |
if( self) | |
{ | |
cls = self->isa; | |
cache = cls->cache; | |
hash = cache->mask; | |
index = (unsigned int) _cmd & hash; | |
do | |
{ | |
method = cache->buckets[ index]; | |
if( ! method) | |
goto recache; | |
index = (index + 1) & cache->mask; | |
} | |
while( method->method_name != _cmd); | |
return( (*method->method_imp)( (id) self, _cmd)); | |
} | |
return( (id) self); | |
recache: | |
/* | |
* internal call _class_lookupMethodAndLoadCache to | |
* look method and load into cache | |
*/ | |
return( 0); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment