Subject: | Unnecessary calls to cwd() |
On line 493 of Archive-Tar-1.28/lib/Archive/Tar.pm, there is the
following call:
my $cwd = cwd();
The Cwd library calls the '/bin/pwd' binary on most Unix systems. This
is a relatively expensive call involving fork() and exec(). However, if
the full path is supplied to the extract_file method, then the cwd()
call is unnecessary as the data is discarded without being used.
Suggestion:
Move the cwd() call inside the "else" clause at line 515. e.g.
### it's a relative path ###
} else {
my $cwd = cwd();
my @dirs = File::Spec::Unix->splitdir( $dirs );
my @cwd = File::Spec->splitdir( $cwd );
$dir = File::Spec->catdir( @cwd, @dirs );
This simple optimisation can significantly speed up file extraction