mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-24 06:50:08 +08:00
Fast paths
This commit is contained in:
parent
ada7b7da0f
commit
ca0cc35661
@ -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
|
|||||||
@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 ->
|
||||||
|
Loading…
Reference in New Issue
Block a user