Replace map { ... }.filterNotNull() with mapNotNull { ... }

This commit is contained in:
Ilya Gorbunov
2015-11-13 23:43:05 +03:00
parent 5b02a59cb7
commit 32151c077e
112 changed files with 197 additions and 269 deletions
+1 -3
View File
@@ -110,14 +110,12 @@ private fun getIndentFunction(indent: String) = when {
private inline fun List<String>.reindent(resultSizeEstimate: Int, indentAddFunction: (String) -> String, indentCutFunction: (String) -> String?): String {
val lastIndex = lastIndex
// TODO: Use mapNotNullIndexed
return mapIndexed { index, value ->
return mapIndexedNotNull { index, value ->
if ((index == 0 || index == lastIndex) && value.isBlank())
null
else
indentCutFunction(value)?.let { cutted -> indentAddFunction(cutted) } ?: value
}
.filterNotNull()
.joinTo(StringBuilder(resultSizeEstimate), "\n")
.toString()
}