diff options
author | Nicholas Clark <nick@ccl4.org> | 2012-02-18 15:01:32 +0100 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2012-02-18 15:01:32 +0100 |
commit | 1c415b640b83a8377f4909a0dea23e17191feb94 (patch) | |
tree | baaa473566faa8d725f19026d03792aaa682421b | |
parent | cc0c9995380d7f5fdea929cf1b829b8f81a91779 (diff) | |
download | perl-smoke-me/DD-5.6-is-uncommon.tar.gz |
Refactor code in Data::Dumper to assume that >=5.8.0 is the common case.smoke-me/DD-5.6-is-uncommon
The 5.8.0 versions of &init_refaddr_format and &format_refaddr are now
compiled by default, and then redefined with their 5.6.x replacements if
it turns out that we're on 5.6.1 or 5.6.2.
Previously both versions were compiled, and the correct pair bound using
typeglob assignment.
-rw-r--r-- | dist/Data-Dumper/Dumper.pm | 51 | ||||
-rw-r--r-- | pod/perldelta.pod | 4 |
2 files changed, 36 insertions, 19 deletions
diff --git a/dist/Data-Dumper/Dumper.pm b/dist/Data-Dumper/Dumper.pm index 06b5eebb49..5cff10003b 100644 --- a/dist/Data-Dumper/Dumper.pm +++ b/dist/Data-Dumper/Dumper.pm @@ -10,7 +10,7 @@ package Data::Dumper; BEGIN { - $VERSION = '2.135_04'; # Don't forget to set version and release + $VERSION = '2.135_05'; # Don't forget to set version and release } # date in POD! #$| = 1; @@ -103,26 +103,39 @@ sub new { return bless($s, $c); } -if ($] >= 5.008) { - # Packed numeric addresses take less memory. Plus pack is faster than sprintf - *init_refaddr_format = sub {}; +# Packed numeric addresses take less memory. Plus pack is faster than sprintf - *format_refaddr = sub { +# Most users of current versions of Data::Dumper will be 5.008 or later. +# Anyone on 5.6.1 and 5.6.2 upgrading will be rare (particularly judging by +# the bug reports from users on those platforms), so for the common case avoid +# complexity, and avoid even compiling the unneeded code. + +sub init_refaddr_format { +} + +sub format_refaddr { require Scalar::Util; pack "J", Scalar::Util::refaddr(shift); - }; -} else { - *init_refaddr_format = sub { - require Config; - my $f = $Config::Config{uvxformat}; - $f =~ tr/"//d; - our $refaddr_format = "0x%" . $f; - }; - - *format_refaddr = sub { - require Scalar::Util; - sprintf our $refaddr_format, Scalar::Util::refaddr(shift); - } +}; + +if ($] < 5.008) { + eval <<'EOC' or die; + no warnings 'redefine'; + my $refaddr_format; + sub init_refaddr_format { + require Config; + my $f = $Config::Config{uvxformat}; + $f =~ tr/"//d; + $refaddr_format = "0x%" . $f; + } + + sub format_refaddr { + require Scalar::Util; + sprintf $refaddr_format, Scalar::Util::refaddr(shift); + } + + 1 +EOC } # @@ -1319,7 +1332,7 @@ modify it under the same terms as Perl itself. =head1 VERSION -Version 2.135_03 (December 19 2011) +Version 2.135_05 (February 18 2012) =head1 SEE ALSO diff --git a/pod/perldelta.pod b/pod/perldelta.pod index 8db7170022..ca650b1f48 100644 --- a/pod/perldelta.pod +++ b/pod/perldelta.pod @@ -343,6 +343,10 @@ L<CPANPLUS::Dist::Build> has been upgraded from version 0.60 to version 0.62. =item * +L<Data::Dumper> has been upgraded from version 2.135_04 to version 2.135_05. + +=item * + L<DB_File> has been upgraded from version 1.824 to version 1.826. =item * |