Avoid an redundant copy in pp_flop
authorFather Chrysostomos <sprout@cpan.org>
Wed, 12 Oct 2011 17:01:41 +0000 (10:01 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Wed, 12 Oct 2011 17:03:34 +0000 (10:03 -0700)
This copy, which occurs with "a".."z" in list context, has been there
since alphabetic ranges were added in commit b1248f16c (perl 3.0 patch
#17 patch #16, continued).

As a side effect, this:

$ ./miniperl -lwe '()=my $undef1..my $undef2'
Use of uninitialized value in range (or flop) at -e line 1.
Use of uninitialized value in range (or flop) at -e line 1.

becomes this:

$ ./miniperl -lwe '()=my $undef1..my $undef2'
Use of uninitialized value $undef2 in range (or flop) at -e line 1.
Use of uninitialized value in range (or flop) at -e line 1.

which is slightly better. :-)

pp_ctl.c
t/lib/warnings/9uninit

index 2406761..b927821 100644 (file)
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -1330,9 +1330,8 @@ PP(pp_flop)
            }
        }
        else {
-           SV * const final = sv_mortalcopy(right);
            STRLEN len;
-           const char * const tmps = SvPV_const(final, len);
+           const char * const tmps = SvPV_const(right, len);
 
            SV *sv = sv_mortalcopy(left);
            SvPV_force_nolen(sv);
index 69be056..2673b48 100644 (file)
@@ -530,11 +530,11 @@ $v = ($m1 ... $m2);
 EXPECT
 Use of uninitialized value $m1 in range (or flop) at - line 7.
 Use of uninitialized value $m2 in range (or flop) at - line 8.
-Use of uninitialized value in range (or flop) at - line 9.
+Use of uninitialized value $m2 in range (or flop) at - line 9.
 Use of uninitialized value in range (or flop) at - line 9.
 Use of uninitialized value $m1 in range (or flop) at - line 12.
 Use of uninitialized value $m2 in range (or flop) at - line 13.
-Use of uninitialized value in range (or flop) at - line 14.
+Use of uninitialized value $m2 in range (or flop) at - line 14.
 Use of uninitialized value in range (or flop) at - line 14.
 ########
 use warnings 'uninitialized';