diff options
author | Father Chrysostomos <sprout@cpan.org> | 2014-11-25 22:41:27 -0800 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2014-11-26 12:32:05 -0800 |
commit | 26cacb72892094a6d49e4e2dacb280426bef6824 (patch) | |
tree | e19c03807570bcb0c533455e5e250ad09f4e3ca4 /t/op/coresubs.t | |
parent | 7ff69a2dfa48adbf53463c1e2d00ff80e4fd34f5 (diff) | |
download | perl-26cacb72892094a6d49e4e2dacb280426bef6824.tar.gz |
Make coresub.t faster by eschewing B::Deparse
Just use B directly to look at the op tree, instead of checking that
deparsed op trees are identical.
Before:
real 0m4.021s
user 0m3.668s
sys 0m0.191s
After:
real 0m0.388s
user 0m0.251s
sys 0m0.080s
Diffstat (limited to 't/op/coresubs.t')
-rw-r--r-- | t/op/coresubs.t | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/t/op/coresubs.t b/t/op/coresubs.t index 612db5c9bb..6fec5f4c75 100644 --- a/t/op/coresubs.t +++ b/t/op/coresubs.t @@ -12,8 +12,7 @@ BEGIN { $^P |= 0x100; } -use B::Deparse; -my $bd = new B::Deparse '-p'; +use B; my %unsupported = map +($_=>1), qw ( __DATA__ __END__ AUTOLOAD BEGIN UNITCHECK CORE DESTROY END INIT CHECK and @@ -83,8 +82,8 @@ while(<$kh>) { # __FILE__ won’t fold with warnings on, and then we get # ‘(eval 21)’ vs ‘(eval 22)’. no warnings 'numeric'; - $core = $bd->coderef2text(eval $hpcode =~ s/my/CORE::/r or die); - $my = $bd->coderef2text(eval $hpcode or die); + $core = op_list(eval $hpcode =~ s/my/CORE::/r or die); + $my = op_list(eval $hpcode or die); is $my, $core, "precedence of CORE::$word without parens"; } @@ -118,6 +117,14 @@ while(<$kh>) { } } +sub B::OP::pushname { push @op_names, shift->name } + +sub op_list { + local @op_names; + B::walkoptree(B::svref_2object($_[0])->ROOT, 'pushname'); + return "@op_names"; +} + sub inlinable_ok { my ($word, $args, $desc_suffix) = @_; $tests += 2; @@ -130,8 +137,8 @@ sub inlinable_ok { "#line 1 This-line-makes-__FILE__-easier-to-test. sub { () = (CORE::$word$full_args) }"; my $my_code = $core_code =~ s/CORE::$word/my$word/r; - my $core = $bd->coderef2text(eval $core_code or die); - my $my = $bd->coderef2text(eval $my_code or die); + my $core = op_list(eval $core_code or die); + my $my = op_list(eval $my_code or die); is $my, $core, "inlinability of CORE::$word $preposition parens $desc_suffix"; } } |