From: gfx Date: Wed, 19 Aug 2009 07:46:12 +0000 (+0900) Subject: Optimize can_xs() X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=e5180c510af71cac1e03d46a43e5c4155f2b604a;p=gitmo%2FClass-MOP.git Optimize can_xs() --- diff --git a/xs/Instance.xs b/xs/Instance.xs index d049f2a..acd2aa9 100644 --- a/xs/Instance.xs +++ b/xs/Instance.xs @@ -79,16 +79,14 @@ BOOT: void* can_xs(SV* self) PREINIT: + CV* const default_method = get_cv("Class::MOP::Instance::get_slot_value", FALSE); SV* const can = newSVpvs_flags("can", SVs_TEMP); - SV* const default_class = newSVpvs_flags("Class::MOP::Instance", SVs_TEMP); - SV* const create_instance = newSVpvs_flags("get_slot_value", SVs_TEMP); - SV* m1; - SV* m2; + SV* const method = newSVpvs_flags("get_slot_value", SVs_TEMP); + SV* code_ref; CODE: - /* $self->can("create_instance") == Class::MOP::Instance->can("create_instance") */ - m1 = mop_call1(aTHX_ self, can, create_instance); - m2 = mop_call1(aTHX_ default_class, can, create_instance); - if(SvROK(m1) && SvROK(m2) && SvRV(m1) == SvRV(m2)){ + /* $self->can("get_slot_value") == \&Class::MOP::Instance::get_slot_value */ + code_ref = mop_call1(aTHX_ self, can, method); + if(SvROK(code_ref) && SvRV(code_ref) == (SV*)default_method){ RETVAL = (void*)&mop_default_instance; } else{