]> git.vpit.fr Git - perl/modules/Lexical-Types.git/commitdiff
Use TARG in lt_pp_padsv
authorVincent Pit <vince@profvince.com>
Mon, 3 Jan 2011 11:20:15 +0000 (12:20 +0100)
committerVincent Pit <vince@profvince.com>
Mon, 3 Jan 2011 11:20:15 +0000 (12:20 +0100)
This is how Perl_pp_padsv gets the SV.

Types.xs

index 4b3856225042fa8b68990568595565812b8cb535..27d5d435dde1c9650d9af67167d4325dba9f0eca 100644 (file)
--- a/Types.xs
+++ b/Types.xs
@@ -487,60 +487,56 @@ STATIC OP *lt_pp_padsv(pTHX) {
  lt_op_info oi;
 
  if (lt_map_fetch(PL_op, &oi)) {
-  PADOFFSET targ = PL_op->op_targ;
-  SV *sv         = PAD_SVl(targ);
-
-  if (sv) {
-   SV *orig_pkg, *type_pkg, *type_meth;
-   int items;
-   dSP;
+  SV *orig_pkg, *type_pkg, *type_meth;
+  int items;
+  dSP;
+  dTARGET;
 
-   ENTER;
-   SAVETMPS;
+  ENTER;
+  SAVETMPS;
 
 #ifdef MULTIPLICITY
-   {
-    STRLEN op_len = oi.orig_pkg_len, tp_len = oi.type_pkg_len;
-    char *buf = oi.buf;
-    orig_pkg  = sv_2mortal(newSVpvn(buf, op_len));
-    SvREADONLY_on(orig_pkg);
-    buf      += op_len;
-    type_pkg  = sv_2mortal(newSVpvn(buf, tp_len));
-    SvREADONLY_on(type_pkg);
-    buf      += tp_len;
-    type_meth = sv_2mortal(newSVpvn(buf, oi.type_meth_len));
-    SvREADONLY_on(type_meth);
-   }
+  {
+   STRLEN op_len = oi.orig_pkg_len, tp_len = oi.type_pkg_len;
+   char *buf = oi.buf;
+   orig_pkg  = sv_2mortal(newSVpvn(buf, op_len));
+   SvREADONLY_on(orig_pkg);
+   buf      += op_len;
+   type_pkg  = sv_2mortal(newSVpvn(buf, tp_len));
+   SvREADONLY_on(type_pkg);
+   buf      += tp_len;
+   type_meth = sv_2mortal(newSVpvn(buf, oi.type_meth_len));
+   SvREADONLY_on(type_meth);
+  }
 #else /* MULTIPLICITY */
-   orig_pkg  = oi.orig_pkg;
-   type_pkg  = oi.type_pkg;
-   type_meth = oi.type_meth;
+  orig_pkg  = oi.orig_pkg;
+  type_pkg  = oi.type_pkg;
+  type_meth = oi.type_meth;
 #endif /* !MULTIPLICITY */
 
-   PUSHMARK(SP);
-   EXTEND(SP, 3);
-   PUSHs(type_pkg);
-   PUSHs(sv);
-   PUSHs(orig_pkg);
-   PUTBACK;
-
-   items = call_sv(type_meth, G_ARRAY | G_METHOD);
-
-   SPAGAIN;
-   switch (items) {
-    case 0:
-     break;
-    case 1:
-     sv_setsv(sv, POPs);
-     break;
-    default:
-     croak("Typed scalar initializer method should return zero or one scalar, but got %d", items);
-   }
-   PUTBACK;
+  PUSHMARK(SP);
+  EXTEND(SP, 3);
+  PUSHs(type_pkg);
+  PUSHTARG;
+  PUSHs(orig_pkg);
+  PUTBACK;
 
-   FREETMPS;
-   LEAVE;
+  items = call_sv(type_meth, G_ARRAY | G_METHOD);
+
+  SPAGAIN;
+  switch (items) {
+   case 0:
+    break;
+   case 1:
+    sv_setsv(TARG, POPs);
+    break;
+   default:
+    croak("Typed scalar initializer method should return zero or one scalar, but got %d", items);
   }
+  PUTBACK;
+
+  FREETMPS;
+  LEAVE;
 
   return oi.old_pp_padsv(aTHX);
  }