From 684600a423cd1247241f00ffc6895aa814193ad3 Mon Sep 17 00:00:00 2001 From: md_5 Date: Thu, 24 Jan 2013 20:27:26 +1100 Subject: [PATCH] Potentially dramatically reduce CPU usage at the cost of 1 megabytes of ram across the entire Bungee instance. --- src/main/java/net/md_5/mendax/datainput/Instruction.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/net/md_5/mendax/datainput/Instruction.java b/src/main/java/net/md_5/mendax/datainput/Instruction.java index af1485c1..9c4e1a17 100644 --- a/src/main/java/net/md_5/mendax/datainput/Instruction.java +++ b/src/main/java/net/md_5/mendax/datainput/Instruction.java @@ -25,12 +25,12 @@ abstract class Instruction { static final Instruction USHORT_BYTE = new UnsignedShortByte(); // Illegal forward references below this line static final Instruction BYTE_INT = new ByteHeader(INT); + // Buffer used to read all skips, make sure it is sufficiently large (1mb packet at the moment) + static final byte[] buf = new byte[1 << 20]; abstract void read(DataInput in) throws IOException; final void skip(DataInput in, int len) throws IOException { - for (int i = 0; i < len; i++) { - in.readUnsignedByte(); - } + in.readFully(buf, 0, len); } }