Commit ca0cc356 authored by Him188's avatar Him188

Fast paths

parent ada7b7da
...@@ -15,6 +15,9 @@ import kotlin.jvm.JvmSynthetic ...@@ -15,6 +15,9 @@ import kotlin.jvm.JvmSynthetic
@Suppress("DuplicatedCode") // false positive. foreach is not common to UByteArray and ByteArray @Suppress("DuplicatedCode") // false positive. foreach is not common to UByteArray and ByteArray
@UseExperimental(ExperimentalUnsignedTypes::class) @UseExperimental(ExperimentalUnsignedTypes::class)
fun ByteArray.toUHexString(separator: String = " ", offset: Int = 0, length: Int = this.size - offset): String { fun ByteArray.toUHexString(separator: String = " ", offset: Int = 0, length: Int = this.size - offset): String {
if (length == 0) {
return ""
}
val lastIndex = offset + length val lastIndex = offset + length
return buildString(length * 2) { return buildString(length * 2) {
this@toUHexString.forEachIndexed { index, it -> this@toUHexString.forEachIndexed { index, it ->
...@@ -32,6 +35,9 @@ fun ByteArray.toUHexString(separator: String = " ", offset: Int = 0, length: Int ...@@ -32,6 +35,9 @@ fun ByteArray.toUHexString(separator: String = " ", offset: Int = 0, length: Int
@Suppress("DuplicatedCode") // false positive. foreach is not common to UByteArray and ByteArray @Suppress("DuplicatedCode") // false positive. foreach is not common to UByteArray and ByteArray
@ExperimentalUnsignedTypes @ExperimentalUnsignedTypes
fun UByteArray.toUHexString(separator: String = " ", offset: Int = 0, length: Int = this.size - offset): String { fun UByteArray.toUHexString(separator: String = " ", offset: Int = 0, length: Int = this.size - offset): String {
if (length == 0) {
return ""
}
val lastIndex = offset + length val lastIndex = offset + length
return buildString(length * 2) { return buildString(length * 2) {
this@toUHexString.forEachIndexed { index, it -> this@toUHexString.forEachIndexed { index, it ->
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment