diff options
author | Nicholas Clark <nick@ccl4.org> | 2009-08-29 11:10:00 +0100 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2009-08-29 11:11:54 +0100 |
commit | ba4c7dd4891fdf4ba3a68fea2323a208aa627586 (patch) | |
tree | 194938812f0b8db9e87341ff513dcb3e6b510d05 | |
parent | 72a2bbbfb72321e2cf05f31b10294c5597890005 (diff) | |
download | perl-ba4c7dd4891fdf4ba3a68fea2323a208aa627586.tar.gz |
Optimise IPC::Open3 with a compile-time constant, eliminating OS-specific code.
($^O isn't going to change at run time, so why carry a lot of code that is
never going to get called on the platform you're running on.)
-rw-r--r-- | lib/IPC/Open3.pm | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/IPC/Open3.pm b/lib/IPC/Open3.pm index 815674b5d4..a7365bdc71 100644 --- a/lib/IPC/Open3.pm +++ b/lib/IPC/Open3.pm @@ -9,7 +9,7 @@ require Exporter; use Carp; use Symbol qw(gensym qualify); -$VERSION = 1.04; +$VERSION = 1.05; @ISA = qw(Exporter); @EXPORT = qw(open3); @@ -181,7 +181,7 @@ sub xfileno { return fileno $_[0]; } -my $do_spawn = $^O eq 'os2' || $^O eq 'MSWin32'; +use constant DO_SPAWN => $^O eq 'os2' || $^O eq 'MSWin32'; sub _open3 { local $Me = shift; @@ -225,7 +225,7 @@ sub _open3 { xpipe $dad_rdr, $kid_wtr if !$dup_rdr; xpipe $dad_err, $kid_err if !$dup_err && $dad_err ne $dad_rdr; - $kidpid = $do_spawn ? -1 : xfork; + $kidpid = DO_SPAWN ? -1 : xfork; if ($kidpid == 0) { # Kid # A tie in the parent should not be allowed to cause problems. untie *STDIN; @@ -272,7 +272,7 @@ sub _open3 { eval { require POSIX; POSIX::_exit(255); }; exit 255; }; - } elsif ($do_spawn) { + } elsif (DO_SPAWN) { # All the bookkeeping of coincidence between handles is # handled in spawn_with_handles. |