Hi Brendan,
Thanks for the patch. It's clearly a yucky hack, but other than that
I see nothing wrong with it. =) I'll apply it.
-Ken
On Jul 5, 2006, at 7:34 AM, Brendan O'Dea wrote:
On Mon, Jul 03, 2006 at 11:43:42PM -0400, Joey Hess wrote:
It's highly annoying that it wants to get the cwd at all in this
case,
since I'm asking for a relative path between two relative
directories and
indeed the same relative path is returned no matter what the cwd is.
I suspect that in this case both calls to cwd could be completly
removed.
Hi Ken,
An optisation to abs2rel is attached which saves two invocations of
cwd() where both arguments are relative. Given that entails fork/exec
of pwd, the benefits can be substantial for a large number of calls.
See Debian bug http://bugs.debian.org/376658 .
--bod
--- PathTools-3.18.orig/lib/File/Spec/Unix.pm 2006-04-28
13:02:16.000000000 +1000
+++ PathTools-3.18/lib/File/Spec/Unix.pm 2006-07-05
20:21:35.000000000 +1000
@@ -364,7 +364,13 @@
# 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];
--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]