Use more mcall1
gfx [Sat, 27 Feb 2010 04:36:39 +0000 (13:36 +0900)]
xs-src/MouseTypeConstraints.xs

index fb8a521..9f1e677 100644 (file)
@@ -387,37 +387,28 @@ mouse_is_an_instance_of(pTHX_ HV* const stash, SV* const instance){
     if(IsObject(instance)){
         dMY_CXT;
         HV* const instance_stash = SvSTASH(SvRV(instance));
-        GV* const instance_isa   = find_method_pvs(instance_stash, "isa");
+        GV* const myisa          = find_method_pvs(instance_stash, "isa");
 
         /* the instance has no own isa method */
-        if(instance_isa == NULL || GvCV(instance_isa) == GvCV(MY_CXT.universal_isa)){
+        if(myisa == NULL || GvCV(myisa) == GvCV(MY_CXT.universal_isa)){
             return stash == instance_stash
                 || mouse_lookup_isa(aTHX_ instance_stash, HvNAME_get(stash));
         }
         /* the instance has its own isa method */
         else {
-            int retval;
-            dSP;
+            SV* package;
+            int ok;
 
             ENTER;
             SAVETMPS;
 
-            PUSHMARK(SP);
-            EXTEND(SP, 2);
-            PUSHs(instance);
-            mPUSHp(HvNAME_get(stash), HvNAMELEN_get(stash));
-            PUTBACK;
-
-            call_sv((SV*)instance_isa, G_SCALAR);
-
-            SPAGAIN;
-            retval = sv_true(POPs);
-            PUTBACK;
+            package = newSVpvn_share(HvNAME_get(stash), HvNAMELEN_get(stash), 0U);
+            ok = sv_true(mcall1s(instance, "isa", sv_2mortal(package)));
 
             FREETMPS;
             LEAVE;
 
-            return retval;
+            return ok;
         }
     }
     return FALSE;
@@ -448,22 +439,11 @@ mouse_can_methods(pTHX_ AV* const methods, SV* const instance){
             }
             else{
                 bool ok;
-                dSP;
 
                 ENTER;
                 SAVETMPS;
 
-                PUSHMARK(SP);
-                EXTEND(SP, 2);
-                PUSHs(instance);
-                PUSHs(sv_mortalcopy(name));
-                PUTBACK;
-
-                call_method("can", G_SCALAR);
-
-                SPAGAIN;
-                ok = sv_true(POPs);
-                PUTBACK;
+                ok = sv_true(mcall1s(instance, "can", sv_mortalcopy(name)));
 
                 FREETMPS;
                 LEAVE;