summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2008-01-25 10:06:08 +0000
committerNicholas Clark <nick@ccl4.org>2008-01-25 10:06:08 +0000
commit267cc4a8114e05742ba94bb40aa5728a5cfaa166 (patch)
tree5ea94eb29f58724c012937dff99f5fc9fd83a6da
parent3bf7733be4441d517a5d743fcbf21dd0ad133d67 (diff)
downloadperl-267cc4a8114e05742ba94bb40aa5728a5cfaa166.tar.gz
Using PL_sv_no in place of any !SvOK() maximum removes a little bit of
hot code in pp_iter. p4raw-id: //depot/perl@33068
-rw-r--r--pp_ctl.c8
-rw-r--r--pp_hot.c6
2 files changed, 11 insertions, 3 deletions
diff --git a/pp_ctl.c b/pp_ctl.c
index 67f450c252..1e4b1e9bf1 100644
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -1922,7 +1922,15 @@ PP(pp_enteriter)
else {
cx->blk_loop.lval_max_u.iterlval = newSVsv(sv);
(void) SvPV_force_nolen(cx->blk_loop.lval_max_u.iterlval);
+ /* This will do the upgrade to SVt_PV, and warn if the value
+ is uninitialised. */
(void) SvPV_nolen_const(right);
+ /* Doing this avoids a check every time in pp_iter in pp_hot.c
+ to replace !SvOK() with a pointer to "". */
+ if (!SvOK(right)) {
+ SvREFCNT_dec(right);
+ cx->blk_loop.ary_min_u.iterary = (AV*) &PL_sv_no;
+ }
}
}
else if (PL_op->op_private & OPpITER_REVERSED) {
diff --git a/pp_hot.c b/pp_hot.c
index 4e55f2678b..4e28a12487 100644
--- a/pp_hot.c
+++ b/pp_hot.c
@@ -1918,10 +1918,10 @@ PP(pp_iter)
if (CxTYPE(cx) != CXt_LOOP_LAZYIV) {
/* string increment */
register SV* cur = cx->blk_loop.lval_max_u.iterlval;
+ /* If the maximum is !SvOK(), pp_enteriter substitutes PL_sv_no.
+ It has SvPVX of "" and SvCUR of 0, which is what we want. */
STRLEN maxlen = 0;
- const char *max =
- SvOK((SV*)av) ?
- SvPV_const((SV*)av, maxlen) : (const char *)"";
+ const char *max = SvPV_const((SV*)av, maxlen);
if (!SvNIOK(cur) && SvCUR(cur) <= maxlen) {
if (SvREFCNT(*itersvp) == 1 && !SvMAGICAL(*itersvp)) {
/* safe to reuse old SV */