pp_pop can be implemented by pp_shift.
Nicholas Clark [Tue, 7 Feb 2006 14:57:36 +0000 (14:57 +0000)]
p4raw-id: //depot/perl@27121

mathoms.c
opcode.h
opcode.pl
pp.c

index f1f20b2..0f0f157 100644 (file)
--- a/mathoms.c
+++ b/mathoms.c
@@ -1049,6 +1049,11 @@ PP(pp_hex)
     return pp_oct();
 }
 
+PP(pp_pop)
+{
+    return pp_shift();
+}
+
 U8 *
 Perl_uvuni_to_utf8(pTHX_ U8 *d, UV uv)
 {
index 4541421..adacc4c 100644 (file)
--- a/opcode.h
+++ b/opcode.h
@@ -932,7 +932,7 @@ EXT Perl_ppaddr_t PL_ppaddr[] /* or perlvars.h */
        MEMBER_TO_FPTR(Perl_pp_anonhash),
        MEMBER_TO_FPTR(Perl_pp_splice),
        MEMBER_TO_FPTR(Perl_pp_push),
-       MEMBER_TO_FPTR(Perl_pp_pop),
+       MEMBER_TO_FPTR(Perl_pp_shift),  /* Perl_pp_pop */
        MEMBER_TO_FPTR(Perl_pp_shift),
        MEMBER_TO_FPTR(Perl_pp_unshift),
        MEMBER_TO_FPTR(Perl_pp_sort),
index b1c50b9..ff171ac 100755 (executable)
--- a/opcode.pl
+++ b/opcode.pl
@@ -81,6 +81,7 @@ my @raw_alias = (
                 Perl_pp_print => ['say'],
                 Perl_pp_index => ['rindex'],
                 Perl_pp_oct => ['hex'],
+                Perl_pp_shift => ['pop'],
                );
 
 while (my ($func, $names) = splice @raw_alias, 0, 2) {
diff --git a/pp.c b/pp.c
index 7789120..1a82a16 100644 (file)
--- a/pp.c
+++ b/pp.c
@@ -4195,24 +4195,12 @@ PP(pp_push)
     RETURN;
 }
 
-PP(pp_pop)
-{
-    dVAR;
-    dSP;
-    AV * const av = (AV*)POPs;
-    SV * const sv = av_pop(av);
-    if (AvREAL(av))
-       (void)sv_2mortal(sv);
-    PUSHs(sv);
-    RETURN;
-}
-
 PP(pp_shift)
 {
     dVAR;
     dSP;
     AV * const av = (AV*)POPs;
-    SV * const sv = av_shift(av);
+    SV * const sv = PL_op->op_type == OP_SHIFT ? av_shift(av) : av_pop(av);
     EXTEND(SP, 1);
     if (!sv)
        RETPUSHUNDEF;