diff options
author | David Mitchell <davem@iabyn.com> | 2009-08-12 01:01:34 +0100 |
---|---|---|
committer | David Mitchell <davem@iabyn.com> | 2009-08-12 01:08:13 +0100 |
commit | 805b10112885d8868f21f8e860792d65e1e6c19d (patch) | |
tree | bf579a0cbd876834f125a2933271f3433837b864 /ext | |
parent | ad2561310d3fa13cf664e8d8b8bb294a23cf9ea4 (diff) | |
download | perl-805b10112885d8868f21f8e860792d65e1e6c19d.tar.gz |
ameliorate B::Deparse slowdown
commit 2990415a45 improved the ability to deparse inlined constants,
but at the cost of having to walk all the symbol tables when each new
B::Deparse object is created. Make this scan instead only happen the first
time its needed.
Diffstat (limited to 'ext')
-rw-r--r-- | ext/B/B/Deparse.pm | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/ext/B/B/Deparse.pm b/ext/B/B/Deparse.pm index 9ba24420b8..5685d0914f 100644 --- a/ext/B/B/Deparse.pm +++ b/ext/B/B/Deparse.pm @@ -570,7 +570,6 @@ sub new { $self->{'ambient_warnings'} = undef; # Assume no lexical warnings $self->{'ambient_hints'} = 0; $self->{'ambient_hinthash'} = undef; - $self->{'inlined_constants'} = $self->scan_for_constants; $self->init(); while (my $arg = shift @_) { @@ -3655,10 +3654,16 @@ sub const { if (class($sv) eq "SPECIAL") { # sv_undef, sv_yes, sv_no return ('undef', '1', $self->maybe_parens("!1", $cx, 21))[$$sv-1]; - } elsif (class($sv) eq "NULL") { + } + if (class($sv) eq "NULL") { return 'undef'; - } elsif ($cx and my $const = $self->{'inlined_constants'}->{ 0 + $sv->object_2svref }) { - return $const; + } + if ($cx) { + unless ($self->{'inlined_constants'}) { + $self->{'inlined_constants'} = $self->scan_for_constants; + } + my $const = $self->{'inlined_constants'}->{ 0 + $sv->object_2svref }; + return $const if $const; } # convert a version object into the "v1.2.3" string in its V magic if ($sv->FLAGS & SVs_RMG) { |