Skip to content

Commit

Permalink
[KLIB Tool] Fix computing cumulative size
Browse files Browse the repository at this point in the history
  • Loading branch information
ddolovov authored and Space Team committed Feb 12, 2025
1 parent 1c10991 commit fb4643b
Showing 1 changed file with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,14 @@ private fun KFile.collectTopLevelElements(irInfo: KlibIrInfo?): List<KlibElement

private val KFile.entries: List<KFile> get() = listFiles

private fun buildElement(name: String, entry: KFile): KlibElementWithSize {
val cumulativeSize = when {
entry.isFile -> entry.size
entry.isDirectory -> entry.entries.sumOf { it.size }
else -> 0L
}
private fun KFile.cumulativeSize(): Long = when {
isFile -> size
isDirectory -> entries.sumOf { it.cumulativeSize() }
else -> 0L
}

return KlibElementWithSize(name, cumulativeSize)
private fun buildElement(name: String, entry: KFile): KlibElementWithSize {
return KlibElementWithSize(name, entry.cumulativeSize())
}

private fun buildIrElement(entry: KFile, irInfo: KlibIrInfo?): KlibElementWithSize {
Expand Down

0 comments on commit fb4643b

Please sign in to comment.