Skip to content
This repository has been archived by the owner on May 26, 2018. It is now read-only.

Commit

Permalink
Change type of connection queue to a concurrent linked queue. Much mo…
Browse files Browse the repository at this point in the history
…re efficient, hopefully. Closes #189
  • Loading branch information
cpw committed Mar 10, 2013
1 parent f647929 commit b301e8e
Showing 1 changed file with 31 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,37 @@
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import java.net.InetSocketAddress;
@@ -77,6 +78,7 @@
@@ -7,6 +8,11 @@
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
+import java.util.Queue;
+import java.util.concurrent.ConcurrentLinkedQueue;
+
+import com.google.common.collect.Queues;
+
import net.minecraft.logging.ILogAgent;
import net.minecraft.network.packet.NetHandler;
import net.minecraft.network.packet.Packet;
@@ -14,7 +20,7 @@
public class MemoryConnection implements INetworkManager
{
private static final SocketAddress field_74444_a = new InetSocketAddress("127.0.0.1", 0);
- private final List field_74442_b = Collections.synchronizedList(new ArrayList());
+ private final Queue<Packet> field_74442_b = Queues.newConcurrentLinkedQueue();
private final ILogAgent field_98214_c;
private MemoryConnection field_74443_c;
private NetHandler field_74440_d;
@@ -65,7 +71,7 @@

while (i-- >= 0 && !this.field_74442_b.isEmpty())
{
- Packet packet = (Packet)this.field_74442_b.remove(0);
+ Packet packet = field_74442_b.poll();
packet.func_73279_a(this.field_74440_d);
}

@@ -77,6 +83,7 @@
if (this.field_74441_e && this.field_74442_b.isEmpty())
{
this.field_74440_d.func_72515_a(this.field_74438_f, this.field_74439_g);
Expand Down

0 comments on commit b301e8e

Please sign in to comment.