Don't create scopes as much as possible
gfx [Mon, 11 Jan 2010 05:49:21 +0000 (14:49 +0900)]
xs-src/Mouse.xs

index 7800a86..df7ca48 100644 (file)
@@ -253,9 +253,6 @@ mouse_class_initialize_object(pTHX_ SV* const meta, SV* const object, HV* const
         croak("You cannot use tied HASH reference as initializing arguments");
     }
 
-    ENTER;
-    SAVETMPS;
-
     if(!ignore_triggers){
         triggers_queue = newAV_mortal();
     }
@@ -313,8 +310,6 @@ mouse_class_initialize_object(pTHX_ SV* const meta, SV* const object, HV* const
         set_slot(object, newSVpvs_flags("__METACLASS__", SVs_TEMP), meta);
     }
 
-    FREETMPS;
-    LEAVE;
 }
 
 static SV*
@@ -353,7 +348,12 @@ mouse_buildall(pTHX_ AV* const xc, SV* const object, SV* const args) {
         PUSHs(args);
         PUTBACK;
 
-        call_sv(AvARRAY(buildall)[i], G_VOID | G_DISCARD);
+        call_sv(AvARRAY(buildall)[i], G_VOID);
+
+        /* discard a scalar which G_VOID returns */
+        SPAGAIN;
+        (void)POPs;
+        PUTBACK;
     }
 }
 
@@ -631,7 +631,13 @@ CODE:
             XPUSHs(object);
             PUTBACK;
 
-            call_sv(AvARRAY(demolishall)[i], G_VOID | G_DISCARD | G_EVAL);
+            call_sv(AvARRAY(demolishall)[i], G_VOID | G_EVAL);
+
+            /* discard a scalar which G_VOID returns */
+            SPAGAIN;
+            (void)POPs;
+            PUTBACK;
+
             if(sv_true(ERRSV)){
                 SV* const e = newSVsv(ERRSV);