From: Brendan O'Dea Date: Thu, 6 Jul 2006 01:02:41 +0000 (+1000) Subject: optimisation for File::Spec::abs2rel where both args are relative X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=e0dc0ff16c00e86c2c9991ba7a9e78f956a37402;p=p5sagit%2Fp5-mst-13.2.git optimisation for File::Spec::abs2rel where both args are relative Message-ID: <20060705150241.GA2244@londo.c47.org> p4raw-id: //depot/perl@28511 --- diff --git a/lib/File/Spec/Unix.pm b/lib/File/Spec/Unix.pm index 8be7329..fc20200 100644 --- a/lib/File/Spec/Unix.pm +++ b/lib/File/Spec/Unix.pm @@ -364,7 +364,13 @@ sub abs2rel { # Can't relativize across volumes return $path unless $path_volume eq $base_volume; - for ($path, $base) { $_ = $self->rel2abs($_) } + if (grep $self->file_name_is_absolute($_), $path, $base) { + for ($path, $base) { $_ = $self->rel2abs($_) } + } + else { + # save a couple of cwd()s if both paths are relative + for ($path, $base) { $_ = $self->catdir('/', $_) } + } my $path_directories = ($self->splitpath($path, 1))[1]; my $base_directories = ($self->splitpath($base, 1))[1];