Skip to content

Commit

Permalink
encoding.pm: inline code that relies on perl 5.21.7 check
Browse files Browse the repository at this point in the history
The result of the perl 5.21.7 check is now stored in a constant. This
allows perl to remove at compile time the unused branches for code that
rely on this check.
  • Loading branch information
dolmen committed Mar 28, 2015
1 parent 3fc8e9d commit 5d76b1d
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions encoding.pm
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use warnings;
use constant {
DEBUG => !!$ENV{PERL_ENCODE_DEBUG},
HAS_PERLIO => eval { require PerlIO::encoding; PerlIO::encoding->VERSION(0.02) },
PERL_5_21_7 => $^V && $^V ge v5.21.7,
};

BEGIN {
Expand Down Expand Up @@ -129,7 +130,7 @@ sub import {
unless ( $arg{Filter} ) {
DEBUG and warn "_exception($name) = ", _exception($name);
if (! _exception($name)) {
if (!$^V || $^V lt v5.21.7) {
if (!PERL_5_21_7) {
${^ENCODING} = $enc;
}
else {
Expand All @@ -144,7 +145,7 @@ sub import {
}
else {
defined( ${^ENCODING} ) and undef ${^ENCODING};
undef ${^E_NCODING} if $^V && $^V ge v5.21.7;
undef ${^E_NCODING} if PERL_5_21_7;

# implicitly 'use utf8'
require utf8; # to fetch $utf8::hint_bits;
Expand Down Expand Up @@ -194,7 +195,7 @@ sub import {
sub unimport {
no warnings;
undef ${^ENCODING};
undef ${^E_NCODING} if $^V && $^V ge v5.21.7;
undef ${^E_NCODING} if PERL_5_21_7;
if (HAS_PERLIO) {
binmode( STDIN, ":raw" );
binmode( STDOUT, ":raw" );
Expand Down

0 comments on commit 5d76b1d

Please sign in to comment.