Another CharSequence.repeat implementation in JS from polyfill of String.repeat.
#KT-3064
This commit is contained in:
@@ -87,9 +87,17 @@ public fun CharSequence.repeat(n: Int): String {
|
|||||||
else -> {
|
else -> {
|
||||||
var result = ""
|
var result = ""
|
||||||
if (!isEmpty()) {
|
if (!isEmpty()) {
|
||||||
val s = this.toString()
|
var s = this.toString()
|
||||||
for (i in 1..n) {
|
var count = n
|
||||||
result += s
|
while (true) {
|
||||||
|
if ((count and 1) == 1) {
|
||||||
|
result += s
|
||||||
|
}
|
||||||
|
count = count ushr 1
|
||||||
|
if (count == 0) {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
s += s
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
|
|||||||
Reference in New Issue
Block a user