From eaa3154b0e267d4369158eaa9e6d3f6640f6728f Mon Sep 17 00:00:00 2001 From: Mike Primm Date: Sat, 11 Aug 2012 23:14:23 -0500 Subject: [PATCH] [Bleeding] Cache packet ID instead of doing lookups each time it is needed --- src/main/java/net/minecraft/server/Packet.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main/java/net/minecraft/server/Packet.java b/src/main/java/net/minecraft/server/Packet.java index 65ac4095ce..bd253cff56 100644 --- a/src/main/java/net/minecraft/server/Packet.java +++ b/src/main/java/net/minecraft/server/Packet.java @@ -21,8 +21,12 @@ public abstract class Packet { public static long p; public static long q; public boolean lowPriority = false; - - public Packet() {} + // CraftBukkit start - calculate packet ID once - used a bunch of times + private int packetID; + + public Packet() { + packetID = ((Integer) a.get(this.getClass())).intValue(); + } // CraftBukkit end static void a(int i, boolean flag, boolean flag1, Class oclass) { if (l.b(i)) { @@ -73,7 +77,7 @@ public abstract class Packet { } public final int k() { - return ((Integer) a.get(this.getClass())).intValue(); + return packetID; // ((Integer) a.get(this.getClass())).intValue(); // CraftBukkit } public static Packet a(DataInputStream datainputstream, boolean flag) throws IOException { // CraftBukkit - throws IOException