Skip to content

Commit 0bf47e1

Browse files
committed
parent: simplify and add strempty() internal
1 parent ce504b5 commit 0bf47e1

29 files changed

+94
-202
lines changed

+stdlib/absolute.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@
2626
return
2727
end
2828

29-
if strlength(base)
29+
if ~strempty(base)
3030
b = stdlib.absolute(base);
3131
else
3232
b = pwd();
3333
end
3434

35-
if strlength(c)
35+
if ~strempty(c)
3636
c = strcat(b, '/', c);
3737
else
3838
c = b;

+stdlib/exists.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
% fileattrib() does not consider URLs to be a file or folder
1919
% at least through Matlab R2025a.
2020

21-
y = strlength(p) && fileattrib(p) == 1;
21+
y = ~strempty(p) && fileattrib(p) == 1;
2222

2323
end
2424

+stdlib/h5create_group.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
else
1919
% avoid confusing creating file ./~/a.h5
2020
file = stdlib.expanduser(file);
21-
assert(strlength(file) > 0, 'h5create_group:filename_error', "filename must be non-empty")
21+
assert(~strempty(file), 'h5create_group:filename_error', "filename must be non-empty")
2222
dcpl = 'H5P_DEFAULT';
2323
if isfile(file)
2424
fid = H5F.open(file, 'H5F_ACC_RDWR', dcpl);

+stdlib/h5save_new.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ function h5save_new(filename, varname, A, sizeA, compressLevel)
1818
error('h5save:shape_error', "only scalar size may be 0")
1919
end
2020

21-
assert(strlength(filename) > 0, 'h5save:filename_error', "filename must be non-empty")
21+
assert(~strempty(filename), 'h5save:filename_error', "filename must be non-empty")
2222

2323
if isscalar(sizeA)
2424
if sizeA == 0

+stdlib/h5variables.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
group {mustBeTextScalar} = ''
1515
end
1616

17-
if ~strlength(group)
17+
if strempty(group)
1818
finf = h5info(file);
1919
else
2020
finf = h5info(file, group);

+stdlib/is_absolute.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111

1212
% not Octave is_absolute_filename() because this is a stricter check for "c:" false
1313

14-
y = strlength(stdlib.root_dir(p)) > 0;
14+
y = ~strempty(stdlib.root_dir(p));
1515

1616
if ispc()
17-
y = y && strlength(stdlib.root_name(p)) > 0;
17+
y = y && ~strempty(stdlib.root_name(p));
1818
end
1919

2020
end

+stdlib/join.m

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,21 @@
1010
rnb = stdlib.root_name(base);
1111
rdo = stdlib.root_dir(other);
1212

13-
if stdlib.is_absolute(other) || (strlength(rno) && ~strcmp(rnb, rno))
13+
if stdlib.is_absolute(other) || (~strempty(rno) && ~strcmp(rnb, rno))
1414

1515
p = other;
1616

17-
elseif strlength(rdo)
17+
elseif ~strempty(rdo)
1818

19-
if strlength(rnb)
19+
if ~strempty(rnb)
2020
p = strcat(rnb, '/', other);
2121
else
2222
p = other;
2323
end
2424

25-
elseif strlength(base)
25+
elseif ~strempty(base)
2626

27-
if strlength(other)
27+
if ~strempty(other)
2828
if endsWith(base, {'/', filesep})
2929
p = strcat(base, other);
3030
else

+stdlib/ncsave_new.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ function ncsave_new(file, varname, A, sizeA, ncdims, compressLevel)
1111
compressLevel (1,1) double {mustBeInteger,mustBeNonnegative} = 0
1212
end
1313

14-
assert(strlength(file) > 0, "stdlib:ncsave_new:file", "Empty filename")
14+
assert(~strempty(file), "stdlib:ncsave_new:file", "Empty filename")
1515

1616
if isscalar(A)
1717
nccreate(file, varname, "Datatype", class(A), "Format", 'netcdf4')

+stdlib/ncvariables.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
end
1616

1717

18-
if strlength(group) == 0
18+
if strempty(group)
1919
finf = ncinfo(file);
2020
else
2121
finf = ncinfo(file, group);

+stdlib/normalize.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
i0 = 1;
2626
if strncmp(n, "/", 1)
2727
n = "/";
28-
elseif ispc() && strlength(n) >= 2 && strlength(stdlib.root_name(p))
28+
elseif ispc() && strlength(n) >= 2 && ~strempty(stdlib.root_name(p))
2929
n = parts(1);
3030
i0 = 2;
3131
else
@@ -62,7 +62,7 @@
6262
end
6363

6464

65-
if ~strlength(n)
65+
if strempty(n)
6666
n = ".";
6767
end
6868

0 commit comments

Comments
 (0)