diff options
author | Carsten Weisse <[email protected]> | 2005-01-17 21:55:45 +0000 |
---|---|---|
committer | Carsten Weisse <[email protected]> | 2005-01-17 21:55:45 +0000 |
commit | 042f0a2c752194f36f9edbb46b9921e5daf881ee (patch) | |
tree | 1c665a0d67b4b6970e527946f69fdc5e4aab03c4 /src/jake2/qcommon | |
parent | 1cb80475c53ba7e595dd65c3a32ff797b9a019b0 (diff) |
garbage optimized with static buffers
Diffstat (limited to 'src/jake2/qcommon')
-rw-r--r-- | src/jake2/qcommon/Cbuf.java | 15 | ||||
-rw-r--r-- | src/jake2/qcommon/Netchan.java | 10 |
2 files changed, 12 insertions, 13 deletions
diff --git a/src/jake2/qcommon/Cbuf.java b/src/jake2/qcommon/Cbuf.java index baa7090..ac36c68 100644 --- a/src/jake2/qcommon/Cbuf.java +++ b/src/jake2/qcommon/Cbuf.java @@ -2,7 +2,7 @@ * Cbuf.java * Copyright (C) 2003 * - * $Id: Cbuf.java,v 1.5 2004-09-22 19:22:09 salomo Exp $ + * $Id: Cbuf.java,v 1.6 2005-01-17 21:54:38 cawe Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -35,6 +35,9 @@ import jake2.util.Lib; */ public final class Cbuf { + private static final byte[] line = new byte[1024]; + private static final byte[] tmp = new byte[8192]; + /** * */ @@ -45,14 +48,12 @@ public final class Cbuf { public static void InsertText(String text) { - byte[] temp = null; int templen = 0; // copy off any commands still remaining in the exec buffer templen = Globals.cmd_text.cursize; if (templen != 0) { - temp = new byte[templen]; - System.arraycopy(Globals.cmd_text.data, 0, temp, 0, templen); + System.arraycopy(Globals.cmd_text.data, 0, tmp, 0, templen); SZ.Clear(Globals.cmd_text); } @@ -61,8 +62,7 @@ public final class Cbuf { // add the copied off data if (templen != 0) { - SZ.Write(Globals.cmd_text, temp, templen); - temp = null; + SZ.Write(Globals.cmd_text, tmp, templen); } } @@ -156,7 +156,6 @@ public final class Cbuf { public static void Execute() { byte[] text = null; - byte[] line = new byte[1024]; Globals.alias_count = 0; // don't allow infinite alias loops @@ -190,7 +189,7 @@ public final class Cbuf { else { i++; Globals.cmd_text.cursize -= i; - byte[] tmp = new byte[Globals.cmd_text.cursize]; + //byte[] tmp = new byte[Globals.cmd_text.cursize]; System.arraycopy(text, i, tmp, 0, Globals.cmd_text.cursize); System.arraycopy(tmp, 0, text, 0, Globals.cmd_text.cursize); diff --git a/src/jake2/qcommon/Netchan.java b/src/jake2/qcommon/Netchan.java index 458bcbd..9f594ef 100644 --- a/src/jake2/qcommon/Netchan.java +++ b/src/jake2/qcommon/Netchan.java @@ -2,7 +2,7 @@ * NetChannel.java * Copyright (C) 2003 * - * $Id: Netchan.java,v 1.4 2004-09-22 19:22:09 salomo Exp $ + * $Id: Netchan.java,v 1.5 2005-01-17 21:55:45 cawe Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -118,6 +118,8 @@ public final class Netchan extends SV_MAIN { qport = Cvar.Get("qport", "" + port, Defines.CVAR_NOSET); } + private static final byte send_buf[] = new byte[Defines.MAX_MSGLEN]; + private static final sizebuf_t send = new sizebuf_t(); /* * =============== Netchan_OutOfBand * @@ -126,8 +128,6 @@ public final class Netchan extends SV_MAIN { //ok. public static void Netchan_OutOfBand(int net_socket, netadr_t adr, int length, byte data[]) { - sizebuf_t send = new sizebuf_t(); - byte send_buf[] = new byte[Defines.MAX_MSGLEN]; // write the packet header SZ.Init(send, send_buf, Defines.MAX_MSGLEN); @@ -194,6 +194,8 @@ public final class Netchan extends SV_MAIN { return send_reliable; } + // private static final byte send_buf[] = new byte[Defines.MAX_MSGLEN]; + // private static final sizebuf_t send = new sizebuf_t(); /* * =============== Netchan_Transmit * @@ -204,8 +206,6 @@ public final class Netchan extends SV_MAIN { * messages. ================ */ public static void Transmit(netchan_t chan, int length, byte data[]) { - sizebuf_t send = new sizebuf_t(); - byte send_buf[] = new byte[Defines.MAX_MSGLEN]; int send_reliable; int w1, w2; |