joinTo/joinToString: Do not call toString on elements that are already CharSequence or Char.

#KT-15557
This commit is contained in:
Ilya Gorbunov
2017-01-12 00:55:17 +03:00
parent 0c27e07e8c
commit 80f2efb625
13 changed files with 44 additions and 48 deletions
@@ -6812,10 +6812,7 @@ public fun <T, A : Appendable> Array<out T>.joinTo(buffer: A, separator: CharSeq
for (element in this) {
if (++count > 1) buffer.append(separator)
if (limit < 0 || count <= limit) {
if (transform != null)
buffer.append(transform(element))
else
buffer.append(if (element == null) "null" else element.toString())
buffer.appendElement(element, transform)
} else break
}
if (limit >= 0 && count > limit) buffer.append(truncated)
@@ -6999,7 +6996,7 @@ public fun <A : Appendable> CharArray.joinTo(buffer: A, separator: CharSequence
if (transform != null)
buffer.append(transform(element))
else
buffer.append(element.toString())
buffer.append(element)
} else break
}
if (limit >= 0 && count > limit) buffer.append(truncated)
@@ -1013,10 +1013,7 @@ public fun <T, A : Appendable> Iterable<T>.joinTo(buffer: A, separator: CharSequ
for (element in this) {
if (++count > 1) buffer.append(separator)
if (limit < 0 || count <= limit) {
if (transform != null)
buffer.append(transform(element))
else
buffer.append(if (element == null) "null" else element.toString())
buffer.appendElement(element, transform)
} else break
}
if (limit >= 0 && count > limit) buffer.append(truncated)
@@ -705,10 +705,7 @@ public fun <T, A : Appendable> Sequence<T>.joinTo(buffer: A, separator: CharSequ
for (element in this) {
if (++count > 1) buffer.append(separator)
if (limit < 0 || count <= limit) {
if (transform != null)
buffer.append(transform(element))
else
buffer.append(if (element == null) "null" else element.toString())
buffer.appendElement(element, transform)
} else break
}
if (limit >= 0 && count > limit) buffer.append(truncated)