remove a couple of parens pairs

This commit is contained in:
Luke Hubmayer-Werner 2022-12-18 03:15:22 +10:30
parent f68940b289
commit 3322fa656b
1 changed files with 2 additions and 2 deletions

View File

@ -5,7 +5,7 @@ val rootPattern = raw"\/(.*)".r
def cd(cwd: String, to: String): String = to match
case rootPattern(absPath) => absPath // Absolute path
case ".." =>
val i = cwd.lastIndexOf('/')
val i = cwd lastIndexOf '/'
if i < 0 then cwd else cwd.substring(0, i) // Up one subfolder
case _ => s"$cwd/$to"
@ -21,7 +21,7 @@ def cd(cwd: String, to: String): String = to match
cwd = cd(cwd, dir)
folders += cwd
case fileSizePattern(sizeStr, filename) =>
fileSizes += (s"$cwd/$filename" -> sizeStr.toInt)
fileSizes += s"$cwd/$filename" -> sizeStr.toInt
case _ => {} // "$ ls", "dir ..."
// Very inefficient way of calculating folder sizes, but cute enough
val folderSizes = folders.map(f => (f, fileSizes.filter((k,v) => k startsWith s"$f/").values.sum)).toMap