Change 33068 by [EMAIL PROTECTED] on 2008/01/25 10:06:08
Using PL_sv_no in place of any !SvOK() maximum removes a little bit of
hot code in pp_iter.
Affected files ...
... //depot/perl/pp_ctl.c#675 edit
... //depot/perl/pp_hot.c#565 edit
Differences ...
==== //depot/perl/pp_ctl.c#675 (text) ====
Index: perl/pp_ctl.c
--- perl/pp_ctl.c#674~33067~ 2008-01-25 00:23:32.000000000 -0800
+++ perl/pp_ctl.c 2008-01-25 02:06:08.000000000 -0800
@@ -1922,7 +1922,15 @@
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) {
==== //depot/perl/pp_hot.c#565 (text) ====
Index: perl/pp_hot.c
--- perl/pp_hot.c#564~33063~ 2008-01-24 05:57:20.000000000 -0800
+++ perl/pp_hot.c 2008-01-25 02:06:08.000000000 -0800
@@ -1918,10 +1918,10 @@
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 */
End of Patch.