Skip to content

Commit 3000e54

Browse files
committed
parent: further speedup
1 parent 4333ad6 commit 3000e54

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

+stdlib/parent.m

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,15 @@
1212
else
1313
% have to drop_slash on input to get expected parent path
1414
p = strip(stdlib.posix(p), "right", "/");
15-
[p, ~, ~] = fileparts(p);
15+
j = strfind(p, "/");
16+
if isempty(j)
17+
p = "";
18+
else
19+
p = extractBefore(p, j(end));
20+
end
1621
end
1722

18-
if isempty(p) || strlength(p) == 0
23+
if p == ""
1924
p = ".";
2025
end
2126

0 commit comments

Comments
 (0)