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
@@ -23,10 +23,7 @@ fun strings(): List<GenericFunction> {
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)
@@ -35,7 +32,7 @@ fun strings(): List<GenericFunction> {
"""
}
exclude(Strings)
body(ArraysOfPrimitives) {
bodyForTypes(ArraysOfPrimitives, *defaultPrimitives.toTypedArray()) { primitive ->
"""
buffer.append(prefix)
var count = 0
@@ -45,7 +42,7 @@ fun strings(): List<GenericFunction> {
if (transform != null)
buffer.append(transform(element))
else
buffer.append(element.toString())
buffer.append(${if (primitive == PrimitiveType.Char) "element" else "element.toString()"})
} else break
}
if (limit >= 0 && count > limit) buffer.append(truncated)