Skip to content

Commit

Permalink
Commented "Cursor?.stringify" defined in CryptomatorDatabase.kt
Browse files Browse the repository at this point in the history
  • Loading branch information
JaniruTEC committed Apr 10, 2024
1 parent aed7e38 commit a6d4776
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -144,15 +144,20 @@ fun Cursor?.stringify(): String {
}

this.moveToPosition(startPos)
return buildString(((this.count + 1) * (columnWidths.values.sum() + this.columnCount))) {
val stringifiedRowCount = this.count + 1 /* Header */
val rowCapacity = columnWidths.values.sum() + this.columnCount /* V-Spaces */ // - 1 (V-Spaces) + 1 (Line breaks)
val capacity = stringifiedRowCount * rowCapacity // + 1 (H-Space) - 1 (No Line break in last line)
return buildString(capacity) {
appendLine(columnNames.asSequence().map { it.padEnd(columnWidths[it]!!) }.joinToString(" "))
appendLine()
values.forEachIndexed { i: Int, value: String ->
append(value.padEnd(columnWidths[columnNames[i % columnCount]]!!))
if ((i == values.size - 1)) {
//Last element
return@buildString
}
if ((i + 1) % columnCount == 0) {
//Last element in line
appendLine()
} else {
append(" ")
Expand Down

0 comments on commit a6d4776

Please sign in to comment.