Skip to content

Commit 95f56e2

Browse files
committed
filename: efficiency, polymorphic char-string in-out
1 parent 8bad03c commit 95f56e2

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

+stdlib/filename.m

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,18 @@
77

88
function f = filename(p)
99
arguments
10-
p (1,1) string
10+
p {mustBeTextScalar}
1111
end
1212

1313
% NOT https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/io/File.html#getName()
1414
% because by our definition, a trailing directory component is not part of the filename
1515
% this is like C++17 filesystem::path::filename
1616

17-
p = stdlib.posix(p);
18-
19-
parts = strsplit(p, "/");
17+
parts = strsplit(stdlib.posix(p), '/');
2018

2119
f = parts{end};
2220

23-
try %#ok<TRYNC>
21+
if isstring(p)
2422
f = string(f);
2523
end
2624

0 commit comments

Comments
 (0)