This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
S_regcppush/pop : don't save PL_reginput
authorDavid Mitchell <davem@iabyn.com>
Mon, 21 May 2012 19:44:50 +0000 (20:44 +0100)
committerDavid Mitchell <davem@iabyn.com>
Wed, 13 Jun 2012 12:32:53 +0000 (13:32 +0100)
currently, S_regcppush() pushes PL_reginput, then S_regcppop() pops its
value and returns it. However, all calls to S_regcppop() are currently in
void context, so nothing actually uses this value. So don't save it in the
first place.

embed.fnc
proto.h
regexec.c

index 551f14a..f7444e9 100644 (file)
--- a/embed.fnc
+++ b/embed.fnc
@@ -1997,7 +1997,7 @@ ERs       |I32    |regtry         |NN regmatch_info *reginfo|NN char **startpos
 ERs    |bool   |reginclass     |NULLOK const regexp * const prog|NN const regnode * const n|NN const U8 * const p|NULLOK STRLEN *lenp\
                                |bool const do_utf8sv_is_utf8
 Es     |CHECKPOINT|regcppush   |NN const regexp *rex|I32 parenfloor
-Es     |char*  |regcppop       |NN regexp *rex
+Es     |void   |regcppop       |NN regexp *rex
 ERsn   |U8*    |reghop3        |NN U8 *s|I32 off|NN const U8 *lim
 ERsM   |SV*    |core_regclass_swash|NULLOK const regexp *prog \
                                |NN const struct regnode *node|bool doinit \
diff --git a/proto.h b/proto.h
index da48b0e..bd23296 100644 (file)
--- a/proto.h
+++ b/proto.h
@@ -6697,7 +6697,7 @@ STATIC I32        S_reg_check_named_buff_matched(pTHX_ const regexp *rex, const regnode
 #define PERL_ARGS_ASSERT_REG_CHECK_NAMED_BUFF_MATCHED  \
        assert(rex); assert(scan)
 
-STATIC char*   S_regcppop(pTHX_ regexp *rex)
+STATIC void    S_regcppop(pTHX_ regexp *rex)
                        __attribute__nonnull__(pTHX_1);
 #define PERL_ARGS_ASSERT_REGCPPOP      \
        assert(rex)
index 5b987ee..76ad57d 100644 (file)
--- a/regexec.c
+++ b/regexec.c
 static void restore_pos(pTHX_ void *arg);
 
 #define REGCP_PAREN_ELEMS 4
-#define REGCP_OTHER_ELEMS 4
+#define REGCP_OTHER_ELEMS 3
 #define REGCP_FRAME_ELEMS 1
 /* REGCP_FRAME_ELEMS are not part of the REGCP_OTHER_ELEMS and
  * are needed for the regexp context stack bookkeeping. */
@@ -388,7 +388,6 @@ S_regcppush(pTHX_ const regexp *rex, I32 parenfloor)
     SSPUSHINT(PL_regsize);
     SSPUSHINT(rex->lastparen);
     SSPUSHINT(rex->lastcloseparen);
-    SSPUSHPTR(PL_reginput);
     SSPUSHUV(SAVEt_REGCONTEXT | elems_shifted); /* Magic cookie. */
 
     return retval;
@@ -410,12 +409,11 @@ S_regcppush(pTHX_ const regexp *rex, I32 parenfloor)
                (IV)(cp), (IV)PL_savestack_ix));                \
     regcpblow(cp)
 
-STATIC char *
+STATIC void
 S_regcppop(pTHX_ regexp *rex)
 {
     dVAR;
     UV i;
-    char *input;
     GET_RE_DEBUG_FLAGS_DECL;
 
     PERL_ARGS_ASSERT_REGCPPOP;
@@ -424,7 +422,6 @@ S_regcppop(pTHX_ regexp *rex)
     i = SSPOPUV;
     assert((i & SAVE_MASK) == SAVEt_REGCONTEXT); /* Check that the magic cookie is there. */
     i >>= SAVE_TIGHT_SHIFT; /* Parentheses elements to pop. */
-    input = (char *) SSPOPPTR;
     rex->lastcloseparen = SSPOPINT;
     rex->lastparen = SSPOPINT;
     PL_regsize = SSPOPINT;
@@ -477,7 +474,6 @@ S_regcppop(pTHX_ regexp *rex)
        ));
     }
 #endif
-    return input;
 }
 
 #define regcpblow(cp) LEAVE_SCOPE(cp)  /* Ignores regcppush()ed data. */