File tree Expand file tree Collapse file tree 1 file changed +6
-13
lines changed
src/main/java/by/andd3dfx/collections Expand file tree Collapse file tree 1 file changed +6
-13
lines changed Original file line number Diff line number Diff line change 22
33import java .util .ArrayDeque ;
44import java .util .Deque ;
5- import java .util .List ;
65
76/**
87 * <pre>
@@ -67,23 +66,17 @@ public static String simplifyPath(String path) {
6766 var chars = path .toCharArray ();
6867 var i = 1 ;
6968 while (i < chars .length ) {
70- switch (chars [i ]) {
71- case '/' :
72- processAccumulated (accumulator , stack );
73- accumulator = new StringBuilder ();
74- break ;
75-
76- default :
77- accumulator .append (chars [i ]);
69+ if (chars [i ] == '/' ) {
70+ processAccumulated (accumulator , stack );
71+ accumulator = new StringBuilder ();
72+ } else {
73+ accumulator .append (chars [i ]);
7874 }
7975 i ++;
8076 }
8177 processAccumulated (accumulator , stack );
8278
83- List <String > folders = stack .stream ()
84- .toList ()
85- .reversed ();
86- return "/" + String .join ("/" , folders );
79+ return "/" + String .join ("/" , stack .reversed ());
8780 }
8881
8982 private static void processAccumulated (StringBuilder accumulator , Deque <String > stack ) {
You can’t perform that action at this time.
0 commit comments