Front page | perl.perl5.changes |
Postings from February 2008
Change 33337: Setting the f flag on length causes the op to be constant folded.
From:
Nicholas Clark
Date:
February 20, 2008 01:30
Subject:
Change 33337: Setting the f flag on length causes the op to be constant folded.
Message ID:
20080220093005.2A675501FD@mx.activestate.com
Change 33337 by nicholas@nicholas-bouvard on 2008/02/20 09:21:53
Setting the f flag on length causes the op to be constant folded.
Affected files ...
... //depot/perl/opcode.h#149 edit
... //depot/perl/opcode.pl#172 edit
... //depot/perl/t/lib/warnings/7fatal#6 edit
Differences ...
==== //depot/perl/opcode.h#149 (text+w) ====
Index: perl/opcode.h
--- perl/opcode.h#148~33267~ 2008-02-09 23:35:45.000000000 -0800
+++ perl/opcode.h 2008-02-20 01:21:53.000000000 -0800
@@ -1658,7 +1658,7 @@
0x0001378e, /* hex */
0x0001378e, /* oct */
0x0001378e, /* abs */
- 0x0001379c, /* length */
+ 0x0001379e, /* length */
0x1322280c, /* substr */
0x0022281c, /* vec */
0x0122291c, /* index */
==== //depot/perl/opcode.pl#172 (xtext) ====
Index: perl/opcode.pl
--- perl/opcode.pl#171~33267~ 2008-02-09 23:35:45.000000000 -0800
+++ perl/opcode.pl 2008-02-20 01:21:53.000000000 -0800
@@ -760,7 +760,7 @@
# String stuff.
-length length ck_lengthconst isTu% S?
+length length ck_lengthconst ifsTu% S?
substr substr ck_substr st@ S S S? S?
vec vec ck_fun ist@ S S S
==== //depot/perl/t/lib/warnings/7fatal#6 (text) ====
Index: perl/t/lib/warnings/7fatal
--- perl/t/lib/warnings/7fatal#5~30124~ 2007-02-04 16:13:08.000000000 -0800
+++ perl/t/lib/warnings/7fatal 2008-02-20 01:21:53.000000000 -0800
@@ -285,7 +285,8 @@
{
use warnings FATAL => qw(void) ;
- length "abc" ;
+ $a = "abc";
+ length $a ;
}
join "", 1,2,3 ;
@@ -293,7 +294,7 @@
print "done\n" ;
EXPECT
Useless use of time in void context at - line 4.
-Useless use of length in void context at - line 8.
+Useless use of length in void context at - line 9.
########
# TODO ? !$Config{usethreads} && $::UTF8 && ($ENV{PERL_DESTRUCT_LEVEL} || 0) > 1 ? "Parser leaks OPs, which leak shared hash keys" : ''
@@ -303,7 +304,8 @@
{
use warnings FATAL => qw(void) ;
- length "abc" ;
+ $a = "abc";
+ length $a ;
}
join "", 1,2,3 ;
@@ -311,7 +313,7 @@
print "done\n" ;
EXPECT
Useless use of time in void context at - line 4.
-Useless use of length in void context at - line 8.
+Useless use of length in void context at - line 9.
########
use warnings FATAL => 'all';
@@ -362,35 +364,39 @@
use warnings FATAL => 'syntax', NONFATAL => 'void' ;
-length "abc";
+$a = "abc";
+length $a;
print STDERR "The End.\n" ;
EXPECT
-Useless use of length in void context at - line 4.
+Useless use of length in void context at - line 5.
The End.
########
use warnings FATAL => 'all', NONFATAL => 'void' ;
-length "abc";
+$a = "abc";
+length $a;
print STDERR "The End.\n" ;
EXPECT
-Useless use of length in void context at - line 4.
+Useless use of length in void context at - line 5.
The End.
########
use warnings FATAL => 'all', NONFATAL => 'void' ;
my $a ; chomp $a;
-length "abc";
+
+$b = "abc" ;
+length $b;
print STDERR "The End.\n" ;
EXPECT
-Useless use of length in void context at - line 5.
+Useless use of length in void context at - line 7.
Use of uninitialized value $a in scalar chomp at - line 4.
########
use warnings FATAL => 'void', NONFATAL => 'void' ;
-
-length "abc";
+$a = "abc";
+length $a;
print STDERR "The End.\n" ;
EXPECT
Useless use of length in void context at - line 4.
@@ -399,8 +405,8 @@
# TODO ? !$Config{usethreads} && $::UTF8 && ($ENV{PERL_DESTRUCT_LEVEL} || 0) > 1 ? "Parser leaks OPs, which leak shared hash keys" : ''
use warnings NONFATAL => 'void', FATAL => 'void' ;
-
-length "abc";
+$a = "abc";
+length $a;
print STDERR "The End.\n" ;
EXPECT
Useless use of length in void context at - line 4.
End of Patch.
-
Change 33337: Setting the f flag on length causes the op to be constant folded.
by Nicholas Clark