Filename | /usr/lib/perl/5.18/File/Spec/Unix.pm |
Statements | Executed 1588 statements in 2.80ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
76 | 6 | 2 | 604µs | 713µs | canonpath | File::Spec::Unix::
6 | 1 | 1 | 323µs | 726µs | abs2rel | File::Spec::Unix::
44 | 7 | 4 | 112µs | 536µs | catdir | File::Spec::Unix::
456 | 6 | 1 | 109µs | 109µs | CORE:subst (opcode) | File::Spec::Unix::
11 | 3 | 3 | 70µs | 295µs | catfile | File::Spec::Unix::
21 | 9 | 4 | 53µs | 61µs | splitpath | File::Spec::Unix::
18 | 2 | 1 | 38µs | 46µs | file_name_is_absolute | File::Spec::Unix::
57 | 2 | 1 | 29µs | 29µs | _same | File::Spec::Unix::
15 | 4 | 3 | 27µs | 27µs | splitdir | File::Spec::Unix::
6 | 1 | 1 | 26µs | 87µs | rel2abs | File::Spec::Unix::
1 | 1 | 1 | 23µs | 49µs | _tmpdir | File::Spec::Unix::
8 | 4 | 3 | 19µs | 19µs | catpath | File::Spec::Unix::
21 | 2 | 1 | 16µs | 16µs | CORE:match (opcode) | File::Spec::Unix::
3 | 1 | 1 | 14µs | 19µs | _cwd | File::Spec::Unix::
2 | 2 | 1 | 13µs | 61µs | tmpdir | File::Spec::Unix::
14 | 4 | 4 | 10µs | 10µs | curdir | File::Spec::Unix::
1 | 1 | 1 | 8µs | 17µs | BEGIN@3 | File::Spec::Unix::
8 | 2 | 2 | 8µs | 8µs | rootdir | File::Spec::Unix::
1 | 1 | 1 | 6µs | 14µs | BEGIN@65 | File::Spec::Unix::
1 | 1 | 1 | 5µs | 19µs | BEGIN@4 | File::Spec::Unix::
1 | 1 | 1 | 5µs | 5µs | CORE:ftdir (opcode) | File::Spec::Unix::
1 | 1 | 1 | 3µs | 3µs | CORE:ftewrite (opcode) | File::Spec::Unix::
1 | 1 | 1 | 2µs | 2µs | updir | File::Spec::Unix::
0 | 0 | 0 | 0s | 0s | _collapse | File::Spec::Unix::
0 | 0 | 0 | 0s | 0s | case_tolerant | File::Spec::Unix::
0 | 0 | 0 | 0s | 0s | devnull | File::Spec::Unix::
0 | 0 | 0 | 0s | 0s | join | File::Spec::Unix::
0 | 0 | 0 | 0s | 0s | no_upwards | File::Spec::Unix::
0 | 0 | 0 | 0s | 0s | path | File::Spec::Unix::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package File::Spec::Unix; | ||||
2 | |||||
3 | 2 | 22µs | 2 | 26µs | # spent 17µs (8+9) within File::Spec::Unix::BEGIN@3 which was called:
# once (8µs+9µs) by Module::Pluggable::Object::BEGIN@4 at line 3 # spent 17µs making 1 call to File::Spec::Unix::BEGIN@3
# spent 9µs making 1 call to strict::import |
4 | 2 | 284µs | 2 | 32µs | # spent 19µs (5+14) within File::Spec::Unix::BEGIN@4 which was called:
# once (5µs+14µs) by Module::Pluggable::Object::BEGIN@4 at line 4 # spent 19µs making 1 call to File::Spec::Unix::BEGIN@4
# spent 14µs making 1 call to vars::import |
5 | |||||
6 | 1 | 400ns | $VERSION = '3.40'; | ||
7 | 1 | 300ns | $VERSION =~ tr/_//; | ||
8 | |||||
9 | # spent 713µs (604+109) within File::Spec::Unix::canonpath which was called 76 times, avg 9µs/call:
# 44 times (348µs+75µs) by File::Spec::Unix::catdir at line 41, avg 10µs/call
# 12 times (96µs+14µs) by File::Spec::Unix::abs2rel at line 157, avg 9µs/call
# 11 times (85µs+10µs) by File::Spec::Unix::catfile at line 46, avg 9µs/call
# 6 times (43µs+4µs) by File::Spec::Unix::rel2abs at line 252, avg 8µs/call
# 2 times (17µs+3µs) by Path::Class::Dir::new at line 44 of Path/Class/Dir.pm, avg 10µs/call
# once (15µs+2µs) by File::Spec::Unix::_tmpdir at line 80 | ||||
10 | 76 | 18µs | my ($self,$path) = @_; | ||
11 | 76 | 10µs | return unless defined $path; | ||
12 | |||||
13 | # Handle POSIX-style node names beginning with double slash (qnx, nto) | ||||
14 | # (POSIX says: "a pathname that begins with two successive slashes | ||||
15 | # may be interpreted in an implementation-defined manner, although | ||||
16 | # more than two leading slashes shall be treated as a single slash.") | ||||
17 | 76 | 11µs | my $node = ''; | ||
18 | 76 | 41µs | my $double_slashes_special = $^O eq 'qnx' || $^O eq 'nto'; | ||
19 | |||||
20 | 76 | 6µs | if ( $double_slashes_special | ||
21 | && ( $path =~ s{^(//[^/]+)/?\z}{}s || $path =~ s{^(//[^/]+)/}{/}s ) ) { | ||||
22 | $node = $1; | ||||
23 | } | ||||
24 | # This used to be | ||||
25 | # $path =~ s|/+|/|g unless ($^O eq 'cygwin'); | ||||
26 | # but that made tests 29, 30, 35, 46, and 213 (as of #13272) to fail | ||||
27 | # (Mainly because trailing "" directories didn't get stripped). | ||||
28 | # Why would cygwin avoid collapsing multiple slashes into one? --jhi | ||||
29 | 76 | 112µs | 76 | 21µs | $path =~ s|/{2,}|/|g; # xx////xx -> xx/xx # spent 21µs making 76 calls to File::Spec::Unix::CORE:subst, avg 280ns/call |
30 | 76 | 93µs | 76 | 20µs | $path =~ s{(?:/\.)+(?:/|\z)}{/}g; # xx/././xx -> xx/xx # spent 20µs making 76 calls to File::Spec::Unix::CORE:subst, avg 263ns/call |
31 | 76 | 85µs | 76 | 12µs | $path =~ s|^(?:\./)+||s unless $path eq "./"; # ./xx -> xx # spent 12µs making 76 calls to File::Spec::Unix::CORE:subst, avg 161ns/call |
32 | 76 | 74µs | 76 | 9µs | $path =~ s|^/(?:\.\./)+|/|; # /../../xx -> xx # spent 9µs making 76 calls to File::Spec::Unix::CORE:subst, avg 124ns/call |
33 | 76 | 70µs | 76 | 8µs | $path =~ s|^/\.\.$|/|; # /.. -> / # spent 8µs making 76 calls to File::Spec::Unix::CORE:subst, avg 105ns/call |
34 | 76 | 112µs | 76 | 38µs | $path =~ s|/\z|| unless $path eq "/"; # xx/ -> xx # spent 38µs making 76 calls to File::Spec::Unix::CORE:subst, avg 504ns/call |
35 | 76 | 139µs | return "$node$path"; | ||
36 | } | ||||
37 | |||||
38 | # spent 536µs (112+424) within File::Spec::Unix::catdir which was called 44 times, avg 12µs/call:
# 20 times (53µs+194µs) by File::Spec::Functions::__ANON__[/usr/lib/perl/5.18/File/Spec/Functions.pm:43] at line 43 of File/Spec/Functions.pm, avg 12µs/call
# 11 times (25µs+105µs) by File::Spec::Unix::catfile at line 48, avg 12µs/call
# 5 times (12µs+47µs) by Path::Class::Dir::stringify at line 81 of Path/Class/Dir.pm, avg 12µs/call
# 3 times (9µs+31µs) by File::Spec::Unix::abs2rel at line 183, avg 13µs/call
# 3 times (6µs+26µs) by File::Spec::Unix::abs2rel at line 184, avg 11µs/call
# once (4µs+11µs) by File::Temp::tempdir at line 1615 of File/Temp.pm
# once (3µs+10µs) by File::Temp::_gettemp at line 434 of File/Temp.pm | ||||
39 | 44 | 8µs | my $self = shift; | ||
40 | |||||
41 | 44 | 105µs | 44 | 424µs | $self->canonpath(join('/', @_, '')); # '' because need a trailing '/' # spent 424µs making 44 calls to File::Spec::Unix::canonpath, avg 10µs/call |
42 | } | ||||
43 | |||||
44 | # spent 295µs (70+225) within File::Spec::Unix::catfile which was called 11 times, avg 27µs/call:
# 6 times (38µs+125µs) by File::Spec::Functions::__ANON__[/usr/lib/perl/5.18/File/Spec/Functions.pm:43] at line 43 of File/Spec/Functions.pm, avg 27µs/call
# 4 times (22µs+72µs) by Path::Class::File::stringify at line 47 of Path/Class/File.pm, avg 23µs/call
# once (9µs+29µs) by File::Temp::tempfile at line 1408 of File/Temp.pm | ||||
45 | 11 | 3µs | my $self = shift; | ||
46 | 11 | 14µs | 11 | 95µs | my $file = $self->canonpath(pop @_); # spent 95µs making 11 calls to File::Spec::Unix::canonpath, avg 9µs/call |
47 | 11 | 2µs | return $file unless @_; | ||
48 | 11 | 13µs | 11 | 130µs | my $dir = $self->catdir(@_); # spent 130µs making 11 calls to File::Spec::Unix::catdir, avg 12µs/call |
49 | 11 | 9µs | $dir .= "/" unless substr($dir,-1) eq "/"; | ||
50 | 11 | 23µs | return $dir.$file; | ||
51 | } | ||||
52 | |||||
53 | 14 | 24µs | # spent 10µs within File::Spec::Unix::curdir which was called 14 times, avg 743ns/call:
# 6 times (5µs+0s) by File::Spec::Functions::__ANON__[/usr/lib/perl/5.18/File/Spec/Functions.pm:43] at line 43 of File/Spec/Functions.pm, avg 767ns/call
# 6 times (4µs+0s) by File::Spec::Unix::abs2rel at line 202, avg 600ns/call
# once (1µs+0s) by Module::Pluggable::Object::BEGIN@4 at line 1103 of File/Find.pm
# once (1µs+0s) by Path::Class::File::BEGIN@8 at line 20 of Path/Class/Dir.pm | ||
54 | |||||
55 | sub devnull { '/dev/null' } | ||||
56 | |||||
57 | 8 | 14µs | # spent 8µs within File::Spec::Unix::rootdir which was called 8 times, avg 963ns/call:
# 6 times (6µs+0s) by File::Spec::Unix::abs2rel at line 191, avg 917ns/call
# 2 times (2µs+0s) by Path::Class::Dir::new at line 45 of Path/Class/Dir.pm, avg 1µs/call | ||
58 | |||||
59 | 1 | 100ns | my $tmpdir; | ||
60 | # spent 49µs (23+26) within File::Spec::Unix::_tmpdir which was called:
# once (23µs+26µs) by File::Spec::Unix::tmpdir at line 86 | ||||
61 | 1 | 200ns | return $tmpdir if defined $tmpdir; | ||
62 | 1 | 1µs | my $self = shift; | ||
63 | 1 | 2µs | my @dirlist = @_; | ||
64 | { | ||||
65 | 3 | 911µs | 2 | 22µs | # spent 14µs (6+8) within File::Spec::Unix::BEGIN@65 which was called:
# once (6µs+8µs) by Module::Pluggable::Object::BEGIN@4 at line 65 # spent 14µs making 1 call to File::Spec::Unix::BEGIN@65
# spent 8µs making 1 call to strict::unimport |
66 | 1 | 2µs | if (${"\cTAINT"}) { # Check for taint mode on perl >= 5.8.0 | ||
67 | require Scalar::Util; | ||||
68 | @dirlist = grep { ! Scalar::Util::tainted($_) } @dirlist; | ||||
69 | } | ||||
70 | elsif ($] < 5.007) { # No ${^TAINT} before 5.8 | ||||
71 | @dirlist = grep { eval { eval('1'.substr $_,0,0) } } @dirlist; | ||||
72 | } | ||||
73 | } | ||||
74 | 1 | 700ns | foreach (@dirlist) { | ||
75 | 2 | 17µs | 2 | 8µs | next unless defined && -d && -w _; # spent 5µs making 1 call to File::Spec::Unix::CORE:ftdir
# spent 3µs making 1 call to File::Spec::Unix::CORE:ftewrite |
76 | 1 | 400ns | $tmpdir = $_; | ||
77 | 1 | 1µs | last; | ||
78 | } | ||||
79 | 1 | 300ns | $tmpdir = $self->curdir unless defined $tmpdir; | ||
80 | 1 | 2µs | 1 | 18µs | $tmpdir = defined $tmpdir && $self->canonpath($tmpdir); # spent 18µs making 1 call to File::Spec::Unix::canonpath |
81 | 1 | 3µs | return $tmpdir; | ||
82 | } | ||||
83 | |||||
84 | # spent 61µs (13+49) within File::Spec::Unix::tmpdir which was called 2 times, avg 31µs/call:
# once (11µs+49µs) by File::Temp::tempdir at line 1615 of File/Temp.pm
# once (2µs+0s) by File::Temp::tempfile at line 1408 of File/Temp.pm | ||||
85 | 2 | 4µs | return $tmpdir if defined $tmpdir; | ||
86 | 1 | 10µs | 1 | 49µs | $tmpdir = $_[0]->_tmpdir( $ENV{TMPDIR}, "/tmp" ); # spent 49µs making 1 call to File::Spec::Unix::_tmpdir |
87 | } | ||||
88 | |||||
89 | 1 | 2µs | # spent 2µs within File::Spec::Unix::updir which was called:
# once (2µs+0s) by Path::Class::File::BEGIN@8 at line 19 of Path/Class/Dir.pm | ||
90 | |||||
91 | sub no_upwards { | ||||
92 | my $self = shift; | ||||
93 | return grep(!/^\.{1,2}\z/s, @_); | ||||
94 | } | ||||
95 | |||||
96 | sub case_tolerant { 0 } | ||||
97 | |||||
98 | sub file_name_is_absolute { | ||||
99 | 18 | 4µs | my ($self,$file) = @_; | ||
100 | 18 | 57µs | 18 | 8µs | return scalar($file =~ m:^/:s); # spent 8µs making 18 calls to File::Spec::Unix::CORE:match, avg 439ns/call |
101 | } | ||||
102 | |||||
103 | sub path { | ||||
104 | return () unless exists $ENV{PATH}; | ||||
105 | my @path = split(':', $ENV{PATH}); | ||||
106 | foreach (@path) { $_ = '.' if $_ eq '' } | ||||
107 | return @path; | ||||
108 | } | ||||
109 | |||||
110 | sub join { | ||||
111 | my $self = shift; | ||||
112 | return $self->catfile(@_); | ||||
113 | } | ||||
114 | |||||
115 | # spent 61µs (53+8) within File::Spec::Unix::splitpath which was called 21 times, avg 3µs/call:
# 3 times (9µs+0s) by File::Spec::Unix::abs2rel at line 182, avg 3µs/call
# 3 times (5µs+0s) by File::Spec::Unix::abs2rel at line 165, avg 2µs/call
# 3 times (3µs+0s) by File::Spec::Unix::abs2rel at line 166, avg 1µs/call
# 3 times (3µs+0s) by File::Spec::Unix::abs2rel at line 171, avg 1µs/call
# 3 times (3µs+0s) by File::Spec::Unix::abs2rel at line 172, avg 1µs/call
# 2 times (14µs+5µs) by Path::Class::File::new at line 21 of Path/Class/File.pm, avg 9µs/call
# 2 times (4µs+0s) by Path::Class::Dir::new at line 44 of Path/Class/Dir.pm, avg 2µs/call
# once (7µs+3µs) by File::Temp::_gettemp at line 445 of File/Temp.pm
# once (4µs+0s) by File::Temp::_gettemp at line 416 of File/Temp.pm | ||||
116 | 21 | 7µs | my ($self,$path, $nofile) = @_; | ||
117 | |||||
118 | 21 | 7µs | my ($volume,$directory,$file) = ('','',''); | ||
119 | |||||
120 | 21 | 4µs | if ( $nofile ) { | ||
121 | $directory = $path; | ||||
122 | } | ||||
123 | else { | ||||
124 | 3 | 15µs | 3 | 8µs | $path =~ m|^ ( (?: .* / (?: \.\.?\z )? )? ) ([^/]*) |xs; # spent 8µs making 3 calls to File::Spec::Unix::CORE:match, avg 3µs/call |
125 | 3 | 4µs | $directory = $1; | ||
126 | 3 | 2µs | $file = $2; | ||
127 | } | ||||
128 | |||||
129 | 21 | 44µs | return ($volume,$directory,$file); | ||
130 | } | ||||
131 | |||||
132 | # spent 27µs within File::Spec::Unix::splitdir which was called 15 times, avg 2µs/call:
# 6 times (12µs+0s) by File::Spec::Unix::abs2rel at line 188, avg 2µs/call
# 6 times (9µs+0s) by File::Spec::Unix::abs2rel at line 189, avg 1µs/call
# 2 times (3µs+0s) by Path::Class::Dir::new at line 45 of Path/Class/Dir.pm, avg 1µs/call
# once (3µs+0s) by File::Temp::_gettemp at line 420 of File/Temp.pm | ||||
133 | 15 | 42µs | return split m|/|, $_[1], -1; # Preserve trailing fields | ||
134 | } | ||||
135 | |||||
136 | # spent 19µs within File::Spec::Unix::catpath which was called 8 times, avg 2µs/call:
# 5 times (10µs+0s) by Path::Class::Dir::stringify at line 81 of Path/Class/Dir.pm, avg 2µs/call
# once (4µs+0s) by File::Temp::_gettemp at line 437 of File/Temp.pm
# once (3µs+0s) by File::Temp::_gettemp at line 448 of File/Temp.pm
# once (2µs+0s) by Path::Class::File::new at line 23 of Path/Class/File.pm | ||||
137 | 8 | 4µs | my ($self,$volume,$directory,$file) = @_; | ||
138 | |||||
139 | 8 | 4µs | if ( $directory ne '' && | ||
140 | $file ne '' && | ||||
141 | substr( $directory, -1 ) ne '/' && | ||||
142 | substr( $file, 0, 1 ) ne '/' | ||||
143 | ) { | ||||
144 | $directory .= "/$file" ; | ||||
145 | } | ||||
146 | else { | ||||
147 | 8 | 2µs | $directory .= $file ; | ||
148 | } | ||||
149 | |||||
150 | 8 | 17µs | return $directory ; | ||
151 | } | ||||
152 | |||||
153 | # spent 726µs (323+403) within File::Spec::Unix::abs2rel which was called 6 times, avg 121µs/call:
# 6 times (323µs+403µs) by File::Spec::Functions::__ANON__[/usr/lib/perl/5.18/File/Spec/Functions.pm:43] at line 43 of File/Spec/Functions.pm, avg 121µs/call | ||||
154 | 6 | 4µs | my($self,$path,$base) = @_; | ||
155 | 6 | 3µs | $base = $self->_cwd() unless defined $base and length $base; | ||
156 | |||||
157 | 6 | 20µs | 12 | 109µs | ($path, $base) = map $self->canonpath($_), $path, $base; # spent 109µs making 12 calls to File::Spec::Unix::canonpath, avg 9µs/call |
158 | |||||
159 | 6 | 1µs | my $path_directories; | ||
160 | 6 | 500ns | my $base_directories; | ||
161 | |||||
162 | 6 | 16µs | 12 | 33µs | if (grep $self->file_name_is_absolute($_), $path, $base) { # spent 33µs making 12 calls to File::Spec::Unix::file_name_is_absolute, avg 3µs/call |
163 | 3 | 9µs | 6 | 87µs | ($path, $base) = map $self->rel2abs($_), $path, $base; # spent 87µs making 6 calls to File::Spec::Unix::rel2abs, avg 14µs/call |
164 | |||||
165 | 3 | 4µs | 3 | 5µs | my ($path_volume) = $self->splitpath($path, 1); # spent 5µs making 3 calls to File::Spec::Unix::splitpath, avg 2µs/call |
166 | 3 | 3µs | 3 | 3µs | my ($base_volume) = $self->splitpath($base, 1); # spent 3µs making 3 calls to File::Spec::Unix::splitpath, avg 1µs/call |
167 | |||||
168 | # Can't relativize across volumes | ||||
169 | 3 | 800ns | return $path unless $path_volume eq $base_volume; | ||
170 | |||||
171 | 3 | 3µs | 3 | 3µs | $path_directories = ($self->splitpath($path, 1))[1]; # spent 3µs making 3 calls to File::Spec::Unix::splitpath, avg 1µs/call |
172 | 3 | 2µs | 3 | 3µs | $base_directories = ($self->splitpath($base, 1))[1]; # spent 3µs making 3 calls to File::Spec::Unix::splitpath, avg 1µs/call |
173 | |||||
174 | # For UNC paths, the user might give a volume like //foo/bar that | ||||
175 | # strictly speaking has no directory portion. Treat it as if it | ||||
176 | # had the root directory for that volume. | ||||
177 | 3 | 2µs | if (!length($base_directories) and $self->file_name_is_absolute($base)) { | ||
178 | $base_directories = $self->rootdir; | ||||
179 | } | ||||
180 | } | ||||
181 | else { | ||||
182 | 3 | 12µs | 6 | 28µs | my $wd= ($self->splitpath($self->_cwd(), 1))[1]; # spent 19µs making 3 calls to File::Spec::Unix::_cwd, avg 6µs/call
# spent 9µs making 3 calls to File::Spec::Unix::splitpath, avg 3µs/call |
183 | 3 | 3µs | 3 | 39µs | $path_directories = $self->catdir($wd, $path); # spent 39µs making 3 calls to File::Spec::Unix::catdir, avg 13µs/call |
184 | 3 | 3µs | 3 | 32µs | $base_directories = $self->catdir($wd, $base); # spent 32µs making 3 calls to File::Spec::Unix::catdir, avg 11µs/call |
185 | } | ||||
186 | |||||
187 | # Now, remove all leading components that are the same | ||||
188 | 6 | 14µs | 6 | 12µs | my @pathchunks = $self->splitdir( $path_directories ); # spent 12µs making 6 calls to File::Spec::Unix::splitdir, avg 2µs/call |
189 | 6 | 10µs | 6 | 9µs | my @basechunks = $self->splitdir( $base_directories ); # spent 9µs making 6 calls to File::Spec::Unix::splitdir, avg 1µs/call |
190 | |||||
191 | 6 | 7µs | 6 | 6µs | if ($base_directories eq $self->rootdir) { # spent 6µs making 6 calls to File::Spec::Unix::rootdir, avg 917ns/call |
192 | return $self->curdir if $path_directories eq $self->rootdir; | ||||
193 | shift @pathchunks; | ||||
194 | return $self->canonpath( $self->catpath('', $self->catdir( @pathchunks ), '') ); | ||||
195 | } | ||||
196 | |||||
197 | 6 | 900ns | my @common; | ||
198 | 6 | 14µs | 6 | 5µs | while (@pathchunks && @basechunks && $self->_same($pathchunks[0], $basechunks[0])) { # spent 5µs making 6 calls to File::Spec::Unix::_same, avg 833ns/call |
199 | 57 | 18µs | push @common, shift @pathchunks ; | ||
200 | 57 | 53µs | 51 | 24µs | shift @basechunks ; # spent 24µs making 51 calls to File::Spec::Unix::_same, avg 467ns/call |
201 | } | ||||
202 | 6 | 21µs | 6 | 4µs | return $self->curdir unless @pathchunks || @basechunks; # spent 4µs making 6 calls to File::Spec::Unix::curdir, avg 600ns/call |
203 | |||||
204 | # @basechunks now contains the directories the resulting relative path | ||||
205 | # must ascend out of before it can descend to $path_directory. If there | ||||
206 | # are updir components, we must descend into the corresponding directories | ||||
207 | # (this only works if they are no symlinks). | ||||
208 | my @reverse_base; | ||||
209 | while( defined(my $dir= shift @basechunks) ) { | ||||
210 | if( $dir ne $self->updir ) { | ||||
211 | unshift @reverse_base, $self->updir; | ||||
212 | push @common, $dir; | ||||
213 | } | ||||
214 | elsif( @common ) { | ||||
215 | if( @reverse_base && $reverse_base[0] eq $self->updir ) { | ||||
216 | shift @reverse_base; | ||||
217 | pop @common; | ||||
218 | } | ||||
219 | else { | ||||
220 | unshift @reverse_base, pop @common; | ||||
221 | } | ||||
222 | } | ||||
223 | } | ||||
224 | my $result_dirs = $self->catdir( @reverse_base, @pathchunks ); | ||||
225 | return $self->canonpath( $self->catpath('', $result_dirs, '') ); | ||||
226 | } | ||||
227 | |||||
228 | sub _same { | ||||
229 | 57 | 68µs | $_[1] eq $_[2]; | ||
230 | } | ||||
231 | |||||
232 | # spent 87µs (26+61) within File::Spec::Unix::rel2abs which was called 6 times, avg 14µs/call:
# 6 times (26µs+61µs) by File::Spec::Unix::abs2rel at line 163, avg 14µs/call | ||||
233 | 6 | 4µs | my ($self,$path,$base ) = @_; | ||
234 | |||||
235 | # Clean up $path | ||||
236 | 6 | 3µs | 6 | 13µs | if ( ! $self->file_name_is_absolute( $path ) ) { # spent 13µs making 6 calls to File::Spec::Unix::file_name_is_absolute, avg 2µs/call |
237 | # Figure out the effective $base and clean it up. | ||||
238 | if ( !defined( $base ) || $base eq '' ) { | ||||
239 | $base = $self->_cwd(); | ||||
240 | } | ||||
241 | elsif ( ! $self->file_name_is_absolute( $base ) ) { | ||||
242 | $base = $self->rel2abs( $base ) ; | ||||
243 | } | ||||
244 | else { | ||||
245 | $base = $self->canonpath( $base ) ; | ||||
246 | } | ||||
247 | |||||
248 | # Glom them together | ||||
249 | $path = $self->catdir( $base, $path ) ; | ||||
250 | } | ||||
251 | |||||
252 | 6 | 12µs | 6 | 47µs | return $self->canonpath( $path ) ; # spent 47µs making 6 calls to File::Spec::Unix::canonpath, avg 8µs/call |
253 | } | ||||
254 | |||||
255 | # Internal routine to File::Spec, no point in making this public since | ||||
256 | # it is the standard Cwd interface. Most of the platform-specific | ||||
257 | # File::Spec subclasses use this. | ||||
258 | # spent 19µs (14+5) within File::Spec::Unix::_cwd which was called 3 times, avg 6µs/call:
# 3 times (14µs+5µs) by File::Spec::Unix::abs2rel at line 182, avg 6µs/call | ||||
259 | 3 | 1µs | require Cwd; | ||
260 | 3 | 20µs | 3 | 5µs | Cwd::getcwd(); # spent 5µs making 3 calls to Cwd::getcwd, avg 2µs/call |
261 | } | ||||
262 | |||||
263 | # Internal method to reduce xx\..\yy -> yy | ||||
264 | sub _collapse { | ||||
265 | my($fs, $path) = @_; | ||||
266 | |||||
267 | my $updir = $fs->updir; | ||||
268 | my $curdir = $fs->curdir; | ||||
269 | |||||
270 | my($vol, $dirs, $file) = $fs->splitpath($path); | ||||
271 | my @dirs = $fs->splitdir($dirs); | ||||
272 | pop @dirs if @dirs && $dirs[-1] eq ''; | ||||
273 | |||||
274 | my @collapsed; | ||||
275 | foreach my $dir (@dirs) { | ||||
276 | if( $dir eq $updir and # if we have an updir | ||||
277 | @collapsed and # and something to collapse | ||||
278 | length $collapsed[-1] and # and its not the rootdir | ||||
279 | $collapsed[-1] ne $updir and # nor another updir | ||||
280 | $collapsed[-1] ne $curdir # nor the curdir | ||||
281 | ) | ||||
282 | { # then | ||||
283 | pop @collapsed; # collapse | ||||
284 | } | ||||
285 | else { # else | ||||
286 | push @collapsed, $dir; # just hang onto it | ||||
287 | } | ||||
288 | } | ||||
289 | |||||
290 | return $fs->catpath($vol, | ||||
291 | $fs->catdir(@collapsed), | ||||
292 | $file | ||||
293 | ); | ||||
294 | } | ||||
295 | |||||
296 | 1 | 2µs | 1; | ||
# spent 5µs within File::Spec::Unix::CORE:ftdir which was called:
# once (5µs+0s) by File::Spec::Unix::_tmpdir at line 75 | |||||
# spent 3µs within File::Spec::Unix::CORE:ftewrite which was called:
# once (3µs+0s) by File::Spec::Unix::_tmpdir at line 75 | |||||
sub File::Spec::Unix::CORE:match; # opcode | |||||
# spent 109µs within File::Spec::Unix::CORE:subst which was called 456 times, avg 239ns/call:
# 76 times (38µs+0s) by File::Spec::Unix::canonpath at line 34, avg 504ns/call
# 76 times (21µs+0s) by File::Spec::Unix::canonpath at line 29, avg 280ns/call
# 76 times (20µs+0s) by File::Spec::Unix::canonpath at line 30, avg 263ns/call
# 76 times (12µs+0s) by File::Spec::Unix::canonpath at line 31, avg 161ns/call
# 76 times (9µs+0s) by File::Spec::Unix::canonpath at line 32, avg 124ns/call
# 76 times (8µs+0s) by File::Spec::Unix::canonpath at line 33, avg 105ns/call |