From 4eeba6d6d433c7ee460c3b6d65f38a98b072a004 Mon Sep 17 00:00:00 2001 From: jaysunxiao Date: Fri, 30 Jul 2021 14:22:17 +0800 Subject: [PATCH] =?UTF-8?q?perf[protocol]:=20=E5=87=8F=E5=B0=91=E8=87=AA?= =?UTF-8?q?=E5=A2=9E=E8=BF=90=E7=AE=97=EF=BC=8C=E6=8F=90=E9=AB=98=E5=8E=8B?= =?UTF-8?q?=E7=BC=A9=E7=AE=97=E6=B3=95=E5=86=99=E5=85=A5long=E7=9A=84?= =?UTF-8?q?=E6=95=88=E7=8E=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../zfoo/protocol/buffer/ByteBufUtils.java | 38 +++++++++---------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/protocol/src/main/java/com/zfoo/protocol/buffer/ByteBufUtils.java b/protocol/src/main/java/com/zfoo/protocol/buffer/ByteBufUtils.java index 9f5d259e..74fce22b 100644 --- a/protocol/src/main/java/com/zfoo/protocol/buffer/ByteBufUtils.java +++ b/protocol/src/main/java/com/zfoo/protocol/buffer/ByteBufUtils.java @@ -198,47 +198,47 @@ public abstract class ByteBufUtils { } byte[] bytes = new byte[9]; - int index = 0; - bytes[index++] = (byte) (mask | 0x80); - bytes[index++] = (byte) (mask >>> 7 | 0x80); - bytes[index++] = (byte) (mask >>> 14 | 0x80); - bytes[index++] = (byte) (mask >>> 21 | 0x80); + bytes[0] = (byte) (mask | 0x80); + bytes[1] = (byte) (mask >>> 7 | 0x80); + bytes[2] = (byte) (mask >>> 14 | 0x80); + bytes[3] = (byte) (mask >>> 21 | 0x80); + int a = (int) (mask >>> 28); int b = (int) (mask >>> 35); if (b == 0) { - bytes[index++] = (byte) a; - byteBuf.writeBytes(bytes, 0, index); + bytes[4] = (byte) a; + byteBuf.writeBytes(bytes, 0, 5); return; } - bytes[index++] = (byte) (a | 0x80); + bytes[4] = (byte) (a | 0x80); a = (int) (mask >>> 42); if (a == 0) { - bytes[index++] = (byte) b; - byteBuf.writeBytes(bytes, 0, index); + bytes[5] = (byte) b; + byteBuf.writeBytes(bytes, 0, 6); return; } - bytes[index++] = (byte) (b | 0x80); + bytes[5] = (byte) (b | 0x80); b = (int) (mask >>> 49); if (b == 0) { - bytes[index++] = (byte) a; - byteBuf.writeBytes(bytes, 0, index); + bytes[6] = (byte) a; + byteBuf.writeBytes(bytes, 0, 7); return; } - bytes[index++] = (byte) (a | 0x80); + bytes[6] = (byte) (a | 0x80); a = (int) (mask >>> 56); if (a == 0) { - bytes[index++] = (byte) b; - byteBuf.writeBytes(bytes, 0, index); + bytes[7] = (byte) b; + byteBuf.writeBytes(bytes, 0, 8); return; } - bytes[index++] = (byte) (b | 0x80); - bytes[index++] = (byte) a; - byteBuf.writeBytes(bytes, 0, index); + bytes[7] = (byte) (b | 0x80); + bytes[8] = (byte) a; + byteBuf.writeBytes(bytes, 0, 9); }