From f3ec93071fd511230458d99d8ed4ca69db9e6ab4 Mon Sep 17 00:00:00 2001 From: Him188 Date: Sun, 2 Feb 2020 20:23:20 +0800 Subject: [PATCH] Fix size --- .../commonMain/kotlin/net.mamoe.mirai/utils/io/ByteArrayUtil.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/utils/io/ByteArrayUtil.kt b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/utils/io/ByteArrayUtil.kt index a9c16377b..41d6ddcea 100644 --- a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/utils/io/ByteArrayUtil.kt +++ b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/utils/io/ByteArrayUtil.kt @@ -81,7 +81,7 @@ fun UByteArray.toUHexString(separator: String = " ", offset: Int = 0, length: In @Suppress("NOTHING_TO_INLINE") inline fun ByteArray.encodeToString(): String = String(this) -fun ByteArray.toReadPacket(offset: Int = 0, length: Int = this.size) = ByteReadPacket(this, offset = offset, length = length) +fun ByteArray.toReadPacket(offset: Int = 0, length: Int = this.size - offset) = ByteReadPacket(this, offset = offset, length = length) @UseExperimental(ExperimentalContracts::class) inline fun ByteArray.read(t: ByteReadPacket.() -> R): R {