mem: Use emplace front/back for deferred packets
authorAndreas Hansson <andreas.hansson@arm.com>
Thu, 19 Mar 2015 08:06:11 +0000 (04:06 -0400)
committerAndreas Hansson <andreas.hansson@arm.com>
Thu, 19 Mar 2015 08:06:11 +0000 (04:06 -0400)
Embrace C++11 for the deferred packets as we actually store the
objects in the data structure, and not just pointers.

src/mem/bridge.cc
src/mem/cache/prefetch/queued.cc
src/mem/packet_queue.cc
src/mem/simple_mem.cc

index 5b925d1cb4d6dea572885c8e08e32344d5e16a83..6bc8c18f2e9fc32a06e8119363a2162d7587d035 100644 (file)
@@ -217,7 +217,7 @@ Bridge::BridgeMasterPort::schedTimingReq(PacketPtr pkt, Tick when)
 
     assert(transmitList.size() != reqQueueLimit);
 
-    transmitList.push_back(DeferredPacket(pkt, when));
+    transmitList.emplace_back(DeferredPacket(pkt, when));
 }
 
 
@@ -232,7 +232,7 @@ Bridge::BridgeSlavePort::schedTimingResp(PacketPtr pkt, Tick when)
         bridge.schedule(sendEvent, when);
     }
 
-    transmitList.push_back(DeferredPacket(pkt, when));
+    transmitList.emplace_back(DeferredPacket(pkt, when));
 }
 
 void
index 318d565dcb1b6e75b5f69efa4ce4d69f2b3dd946..97ea4eee6f2d7d63a809353b08cdb8c1f3eda0ff 100644 (file)
@@ -149,7 +149,7 @@ QueuedPrefetcher::notify(const PacketPtr &pkt)
             DPRINTF(HWPrefetch, "Prefetch queued. "
                     "addr:%#x tick:%lld.\n", pf_addr, pf_time);
 
-            pfq.push_back(DeferredPacket(pf_time, pf_pkt));
+            pfq.emplace_back(DeferredPacket(pf_time, pf_pkt));
         }
     }
 
index 1b2c6993056f5e4d9720d0434dd79e46e7ef2aea..86cf599ab7bab7042f1b00e061ecdfb0681e4e3b 100644 (file)
@@ -142,7 +142,7 @@ PacketQueue::schedSendTiming(PacketPtr pkt, Tick when, bool force_order)
         // note that currently we ignore a potentially outstanding retry
         // and could in theory put a new packet at the head of the
         // transmit list before retrying the existing packet
-        transmitList.push_front(DeferredPacket(when, pkt));
+        transmitList.emplace_front(DeferredPacket(when, pkt));
         schedSendEvent(when);
         return;
     }
@@ -157,7 +157,7 @@ PacketQueue::schedSendTiming(PacketPtr pkt, Tick when, bool force_order)
 
     // list is non-empty and this belongs at the end
     if (when >= transmitList.back().tick) {
-        transmitList.push_back(DeferredPacket(when, pkt));
+        transmitList.emplace_back(DeferredPacket(when, pkt));
         return;
     }
 
@@ -169,7 +169,7 @@ PacketQueue::schedSendTiming(PacketPtr pkt, Tick when, bool force_order)
     ++i; // already checked for insertion at front
     while (i != transmitList.end() && when >= i->tick)
         ++i;
-    transmitList.insert(i, DeferredPacket(when, pkt));
+    transmitList.emplace(i, DeferredPacket(when, pkt));
 }
 
 void
@@ -233,7 +233,7 @@ PacketQueue::sendDeferredPacket()
         schedSendEvent(deferredPacketReadyTime());
     } else {
         // put the packet back at the front of the list
-        transmitList.push_front(dp);
+        transmitList.emplace_front(dp);
     }
 }
 
index 52fd753c8c99734c48a250c56039c108f3fde693..1803394594d761ea28d64577ee2afbad0351f710 100644 (file)
@@ -161,7 +161,7 @@ SimpleMemory::recvTimingReq(PacketPtr pkt)
         // to keep things simple (and in order), we put the packet at
         // the end even if the latency suggests it should be sent
         // before the packet(s) before it
-        packetQueue.push_back(DeferredPacket(pkt, curTick() + getLatency()));
+        packetQueue.emplace_back(DeferredPacket(pkt, curTick() + getLatency()));
         if (!retryResp && !dequeueEvent.scheduled())
             schedule(dequeueEvent, packetQueue.back().tick);
     } else {