From f099972beecb97e608b2a66beb61b33fad3374ce Mon Sep 17 00:00:00 2001 From: Graham Date: Fri, 22 Jan 2021 20:50:20 +0000 Subject: [PATCH] Make the nioBufferCount() > 1 case in crc32 more concise Signed-off-by: Graham --- .../src/main/kotlin/org/openrs2/buffer/ByteBufExtensions.kt | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/buffer/src/main/kotlin/org/openrs2/buffer/ByteBufExtensions.kt b/buffer/src/main/kotlin/org/openrs2/buffer/ByteBufExtensions.kt index 85108b04..42de507f 100644 --- a/buffer/src/main/kotlin/org/openrs2/buffer/ByteBufExtensions.kt +++ b/buffer/src/main/kotlin/org/openrs2/buffer/ByteBufExtensions.kt @@ -103,11 +103,7 @@ public fun ByteBuf.crc32(index: Int, len: Int): Int { when { hasArray() -> crc.update(array(), arrayOffset() + index, len) - count > 1 -> { - for (b in nioBuffers(index, len)) { - crc.update(b) - } - } + count > 1 -> nioBuffers(index, len).forEach(crc::update) count == 1 -> crc.update(nioBuffer(index, len)) else -> crc.update(ByteBufUtil.getBytes(this, index, len, false)) }