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
@@ -12158,10 +12158,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)
@@ -12345,7 +12342,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)
@@ -2000,10 +2000,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)
@@ -1271,10 +1271,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)