Skip to content

Commit f12c290

Browse files
committed
join: increase efficiency
1 parent 04fa066 commit f12c290

File tree

1 file changed

+14
-23
lines changed

1 file changed

+14
-23
lines changed

+stdlib/join.m

Lines changed: 14 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -11,40 +11,31 @@
1111
b = stdlib.drop_slash(base);
1212
o = stdlib.drop_slash(other);
1313

14-
Lb = stdlib.len(b);
15-
Lo = stdlib.len(o);
16-
17-
if ~Lb && ~Lo
18-
p = "";
19-
return
20-
end
21-
22-
if ~Lb
23-
p = o;
24-
return
25-
end
26-
27-
if ~stdlib.len(o)
28-
p = b;
29-
return
30-
end
31-
3214
if stdlib.isoctave()
33-
p = javaObject("java.io.File", b).toPath().resolve(o).toString();
15+
o = javaObject("java.io.File", b).toPath().resolve(o);
16+
p = jPosix(o);
3417
elseif use_java
35-
p = string(java.io.File(b).toPath().resolve(o));
18+
o = java.io.File(b).toPath().resolve(o);
19+
p = jPosix(o);
3620
else
3721

3822
if startsWith(o, "/") || (ispc && stdlib.is_absolute(o))
3923
p = o;
4024
return
4125
end
4226

43-
p = b + "/" + o;
44-
27+
p = b;
28+
if strlength(o)
29+
if endsWith(p, "/")
30+
p = p + o;
31+
elseif strlength(p)
32+
p = p + "/" + o;
33+
else
34+
p = o;
35+
end
4536
end
4637

47-
p = stdlib.posix(p);
38+
end
4839

4940
end
5041

0 commit comments

Comments
 (0)