diff options
author | Nicholas Clark <nick@ccl4.org> | 2005-11-08 20:43:11 +0000 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2005-11-08 20:43:11 +0000 |
commit | f7997f866fdcafc687fbaa99dbeb48f109b2e8d8 (patch) | |
tree | 541b3865d1bac5deca2518904f20189445cba75e /pp_ctl.c | |
parent | 2b2a7552a15f8e825abc97e9ae95ff726e336474 (diff) | |
download | perl-f7997f866fdcafc687fbaa99dbeb48f109b2e8d8.tar.gz |
Eliminate duplicate strlen()s by explicitly calling it.
Note two places for future audit with FIXME.
Convert a SvPVX_const to SvPVX_const_nolen, where the length is unused.
p4raw-id: //depot/perl@26049
Diffstat (limited to 'pp_ctl.c')
-rw-r--r-- | pp_ctl.c | 16 |
1 files changed, 11 insertions, 5 deletions
@@ -2716,6 +2716,7 @@ Perl_sv_compile_2op(pTHX_ SV *sv, OP** startop, const char *code, PAD** padp) /* startop op_free() this to undo. */ /* code Short string id of the caller. */ { + /* FIXME - how much of this code is common with pp_entereval? */ dVAR; dSP; /* Make POPBLOCK work. */ PERL_CONTEXT *cx; SV **newsp; @@ -2728,6 +2729,7 @@ Perl_sv_compile_2op(pTHX_ SV *sv, OP** startop, const char *code, PAD** padp) char *safestr; int runtime; CV* runcv = Nullcv; /* initialise to avoid compiler warnings */ + STRLEN len; ENTER; lex_start(sv); @@ -2756,8 +2758,9 @@ Perl_sv_compile_2op(pTHX_ SV *sv, OP** startop, const char *code, PAD** padp) (i.e. before run-time proper). To work around the coredump that ensues, we always turn GvMULTI_on for any globals that were introduced within evals. See force_ident(). GSAR 96-10-12 */ - safestr = savepv(tmpbuf); - SAVEDELETE(PL_defstash, safestr, strlen(safestr)); + len = strlen(tmpbuf); + safestr = savepvn(tmpbuf, len); + SAVEDELETE(PL_defstash, safestr, len); SAVEHINTS(); #ifdef OP_IN_REGISTER PL_opsave = op; @@ -3310,6 +3313,8 @@ PP(pp_require) else SETERRNO(0, SS_NORMAL); + /* FIXME - is name ever assigned to after the SvPVX_const that also set + len? If no, then this strlen() is superfluous. */ /* Assume success here to prevent recursive requirement. */ len = strlen(name); /* Check whether a hook in @INC has already filled %INC */ @@ -3387,7 +3392,7 @@ PP(pp_entereval) CV* runcv; U32 seq; - if (!SvPV_const(sv,len)) + if (!SvPV_nolen_const(sv)) RETPUSHUNDEF; TAINT_PROPER("eval"); @@ -3415,8 +3420,9 @@ PP(pp_entereval) (i.e. before run-time proper). To work around the coredump that ensues, we always turn GvMULTI_on for any globals that were introduced within evals. See force_ident(). GSAR 96-10-12 */ - safestr = savepv(tmpbuf); - SAVEDELETE(PL_defstash, safestr, strlen(safestr)); + len = strlen(tmpbuf); + safestr = savepvn(tmpbuf, len); + SAVEDELETE(PL_defstash, safestr, len); SAVEHINTS(); PL_hints = PL_op->op_targ; SAVESPTR(PL_compiling.cop_warnings); |