Use ArrayDeque instead of LinkedList 23/32023/2
authorRobert Varga <robert.varga@pantheon.sk>
Sat, 2 Jan 2016 17:05:02 +0000 (18:05 +0100)
committerGerrit Code Review <gerrit@opendaylight.org>
Tue, 5 Jan 2016 19:06:10 +0000 (19:06 +0000)
We are using the list as a Queue, ArrayDeque has less memory overhead
and linear element packing. It is also documented as to be likely faster
than LinkedList.

Change-Id: I270e307360402350e3aab01ee3a8177283a85118
Signed-off-by: Robert Varga <robert.varga@pantheon.sk>
opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/RaftActorServerConfigurationSupport.java

index f969e3d67d46b53920e2b41b5fa3078fe5efd5f1..bff21337de19efd081f7a6e4eb2c4b8ed14a10a9 100644 (file)
@@ -11,7 +11,7 @@ import akka.actor.ActorRef;
 import akka.actor.ActorSelection;
 import akka.actor.Cancellable;
 import com.google.common.base.Preconditions;
-import java.util.LinkedList;
+import java.util.ArrayDeque;
 import java.util.Queue;
 import java.util.UUID;
 import javax.annotation.Nullable;
@@ -43,7 +43,7 @@ class RaftActorServerConfigurationSupport {
 
     private final RaftActorContext raftContext;
 
-    private final Queue<ServerOperationContext<?>> pendingOperationsQueue = new LinkedList<>();
+    private final Queue<ServerOperationContext<?>> pendingOperationsQueue = new ArrayDeque<>();
 
     private OperationState currentOperationState = IDLE;