Use StringBuilder in String.times()

Has better performance than StringBuffer
This commit is contained in:
Nikola Trubitsyn 2017-12-26 01:44:21 +03:00 committed by GitHub
parent 67ae85cf55
commit 9c44837d0c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 3 deletions

View File

@ -1,9 +1,9 @@
package com.simplemobiletools.contacts.overloads
operator fun String.times(x: Int): String {
val stringBuffer = StringBuffer()
val sb = StringBuilder()
for (i in 1..x) {
stringBuffer.append(this)
sb.append(this)
}
return stringBuffer.toString()
return sb.toString()
}