mirror of
https://github.com/jlengrand/ktor.git
synced 2026-03-10 08:31:20 +00:00
Replace copy loop with substring in native charset encoder
This commit is contained in:
@@ -71,18 +71,12 @@ internal actual fun CharsetEncoder.encodeImpl(input: CharSequence, fromIndex: In
|
||||
val length = toIndex - fromIndex
|
||||
if (length == 0) return 0
|
||||
|
||||
val chars = CharArray(length)
|
||||
val chars = input.substring(fromIndex, toIndex).toCharArray()
|
||||
val charset = iconvCharsetName(_charset._name)
|
||||
val cd: COpaquePointer? = iconv_open(charset, platformUtf16)
|
||||
checkErrors(cd, charset)
|
||||
|
||||
@Suppress("ReplaceRangeToWithUntil")
|
||||
for (index in 0..length - 1) {
|
||||
chars[index] = input[fromIndex + index]
|
||||
}
|
||||
|
||||
var charsConsumed = 0
|
||||
|
||||
try {
|
||||
dst.writeDirect { buffer ->
|
||||
chars.usePinned { pinned ->
|
||||
|
||||
Reference in New Issue
Block a user