Skip to content

Commit 239ce36

Browse files
committed
vectorize
compatible
1 parent f2b253a commit 239ce36

33 files changed

+108
-129
lines changed

+stdlib/+dotnet/get_owner.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
elseif isfile(p)
1616
fsec = System.IO.File.GetAccessControl(p);
1717
else
18-
o = string.empty;
18+
o = "";
1919
return
2020
end
2121

+stdlib/+java/inode.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
function i = inode(p)
22

3-
opt = javaMethod("values", "java.nio.file.LinkOption");
3+
opt = java.nio.file.LinkOption.values();
44

55
jp = javaPathObject(stdlib.absolute(p));
66
% Java 1.8 benefits from the absolute() for stability--it's not an issue
77
% on every computer.
88

9-
i = javaMethod("getAttribute", "java.nio.file.Files", jp, "unix:ino", opt);
9+
i = java.nio.file.Files.getAttribute(jp, "unix:ino", opt);
1010

1111
i = uint64(i);
1212
end

+stdlib/checkout_license.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
function [ok, featureName] = checkout_license(packageName)
1414
arguments
15-
packageName {mustBeTextScalar}
15+
packageName (1,1) string
1616
end
1717

1818
ok = false;
@@ -62,4 +62,4 @@
6262

6363
p = com.mathworks.product.util.ProductIdentifier.get(name).getName().string; %#ok<JAPIMATHWORKS>
6464

65-
end
65+
end

+stdlib/drop_slash.m

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
%% DROP_SLASH drop repeated and trailing slash
22
%
33

4-
function d = drop_slash(p)
4+
function d = drop_slash(filepath)
55
arguments
6-
p {mustBeTextScalar}
6+
filepath string
77
end
88

9-
s = stdlib.posix(p);
9+
s = stdlib.posix(filepath);
1010

1111
% drop repeated slashes inside string
1212
d = regexprep(s, '/+', '/');
1313

1414
% drop all trailing slashes
15-
if ~strcmp(d, '/') && ~strcmp(d, stdlib.root(s))
16-
d = regexprep(d, '/$', '');
17-
end
15+
i = ~strcmp(d, '/') & ~strcmp(d, stdlib.root(s));
16+
17+
d(i) = regexprep(d(i), '/$', '');
1818

1919
end

+stdlib/h5exists.m

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,16 @@
77
% * exists: boolean
88

99
function exists = h5exists(file, variable)
10-
arguments
11-
file
12-
variable (1,1) string
13-
end
14-
15-
exists = false;
1610

1711
try
1812
h5info(file, variable);
1913
exists = true;
2014
catch e
21-
if ~strcmp(e.identifier, 'MATLAB:imagesci:h5info:unableToFind')
15+
if e.identifier ~= "MATLAB:imagesci:h5info:unableToFind"
2216
rethrow(e)
2317
end
18+
19+
exists = false;
2420
end
2521

2622
end

+stdlib/inode.m

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,16 @@
88

99
function [i, b] = inode(file, backend)
1010
arguments
11-
file {mustBeTextScalar}
11+
file string
1212
backend (1,:) string = ["java", "python", "sys"]
1313
end
1414

1515
[fun, b] = hbackend(backend, "inode");
1616

17-
i = fun(file);
17+
if isscalar(file)
18+
i = fun(file);
19+
else
20+
i = arrayfun(fun, file);
21+
end
1822

1923
end

+stdlib/is_executable_binary.m

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@
1616
% (ELF) formats.
1717

1818
function y = is_executable_binary(filename)
19-
arguments
20-
filename {mustBeTextScalar}
21-
end
2219

2320
y = false;
2421

+stdlib/is_hdf5.m

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
%% IS_HDF5 is file an HDF5 file?
22

33
function is_hdf5 = is_hdf5(filename)
4-
arguments
5-
filename {mustBeTextScalar}
6-
end
74

85
is_hdf5 = H5F.is_hdf5(filename) == 1;
96

+stdlib/is_mex_fun.m

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
%% IS_MEX_FUN detect if a function is loaded as MEX or plain .m
22

33
function y = is_mex_fun(name)
4-
arguments
5-
name {mustBeTextScalar}
6-
end
74

85
% this method is 4x faster than using inmem() and processing strings
96

+stdlib/is_mount.m

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,16 @@
1414

1515
function [ok, b] = is_mount(filepath, backend)
1616
arguments
17-
filepath {mustBeTextScalar}
17+
filepath string
1818
backend (1,:) string = ["python", "sys"]
1919
end
2020

2121
[fun, b] = hbackend(backend, "is_mount");
2222

23-
ok = fun(filepath);
23+
if isscalar(filepath)
24+
ok = fun(filepath);
25+
else
26+
ok = arrayfun(fun, filepath);
27+
end
2428

2529
end

0 commit comments

Comments
 (0)