Skip to content

Commit 36a7dc4

Browse files
bdmendesJD557
andauthored
Avoid allocation
Co-authored-by: João Costa <jdpc557@gmail.com>
1 parent d5d001e commit 36a7dc4

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

modules/io/src/main/scala/com/kevel/apso/io/FileDescriptor.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ trait FileDescriptor {
155155
* the new file descriptor with the updated path
156156
*/
157157
def cd(pathString: String): Self = {
158-
pathString.split("/").map(_.trim).toList.foldLeft(this.asInstanceOf[Self]) {
158+
pathString.split("/").iterator.map(_.trim).foldLeft(this.asInstanceOf[Self]) {
159159
case (acc, "." | "") => acc
160160
case (acc, "..") => acc.parent().asInstanceOf[Self]
161161
case (acc, segment) => acc.child(segment).asInstanceOf[Self]

0 commit comments

Comments
 (0)