Change 30717 by [EMAIL PROTECTED] on 2007/03/23 11:58:22
Integrate:
[ 30481]
As SvUPGRADE() is a macro wrapping a call to sv_upgrade() inside
a check on the existing SvTYPE(), there's no need to wrap it inside
another explcit check of SvTYPE(). This won't make any difference to
the output of an optimising compiler, but it makes the source clearer.
[ 30606]
The code in newCONDOP can be made visibly simpler by using intermediate
variables. It's also 8 bytes smaller with -Os
Affected files ...
... //depot/maint-5.8/perl/op.c#209 integrate
... //depot/maint-5.8/perl/pp_ctl.c#177 integrate
... //depot/maint-5.8/perl/sv.c#350 integrate
Differences ...
==== //depot/maint-5.8/perl/op.c#209 (text) ====
Index: perl/op.c
--- perl/op.c#208~30701~ 2007-03-22 15:25:21.000000000 -0700
+++ perl/op.c 2007-03-23 04:58:22.000000000 -0700
@@ -3776,20 +3776,17 @@
scalarboolean(first);
if (first->op_type == OP_CONST) {
+ /* Left or right arm of the conditional? */
+ const bool left = SvTRUE(((SVOP*)first)->op_sv);
+ OP *const live = left ? trueop : falseop;
+ OP *const dead = left ? falseop : trueop;
if (first->op_private & OPpCONST_BARE &&
first->op_private & OPpCONST_STRICT) {
no_bareword_allowed(first);
}
- if (SvTRUE(((SVOP*)first)->op_sv)) {
- op_free(first);
- op_free(falseop);
- return trueop;
- }
- else {
- op_free(first);
- op_free(trueop);
- return falseop;
- }
+ op_free(first);
+ op_free(dead);
+ return live;
}
NewOp(1101, logop, 1, LOGOP);
logop->op_type = OP_COND_EXPR;
==== //depot/maint-5.8/perl/pp_ctl.c#177 (text) ====
Index: perl/pp_ctl.c
--- perl/pp_ctl.c#176~30480~ 2007-03-05 15:40:56.000000000 -0800
+++ perl/pp_ctl.c 2007-03-23 04:58:22.000000000 -0700
@@ -241,8 +241,7 @@
SV * const sv = cx->sb_targ;
MAGIC *mg;
I32 i;
- if (SvTYPE(sv) < SVt_PVMG)
- (void)SvUPGRADE(sv, SVt_PVMG);
+ (void)SvUPGRADE(sv, SVt_PVMG);
if (!(mg = mg_find(sv, PERL_MAGIC_regex_global))) {
#ifdef PERL_OLD_COPY_ON_WRITE
if (SvIsCOW(lsv))
==== //depot/maint-5.8/perl/sv.c#350 (text) ====
Index: perl/sv.c
--- perl/sv.c#349~30703~ 2007-03-22 16:14:35.000000000 -0700
+++ perl/sv.c 2007-03-23 04:58:22.000000000 -0700
@@ -3996,9 +3996,7 @@
{
MAGIC* mg;
- if (SvTYPE(sv) < SVt_PVMG) {
- (void)SvUPGRADE(sv, SVt_PVMG);
- }
+ (void)SvUPGRADE(sv, SVt_PVMG);
Newxz(mg, 1, MAGIC);
mg->mg_moremagic = SvMAGIC(sv);
SvMAGIC_set(sv, mg);
End of Patch.