table: optimize removal of PIT in-records

Most call sites already have an iterator that can be used directly,
so change deleteInRecord() to accept an iterator instead of doing
another list lookup.

Change-Id: Ie097f4bc4b13e7428e0580ed7cf4dcb506a009f7
diff --git a/daemon/fw/forwarder.cpp b/daemon/fw/forwarder.cpp
index 906c2f2..4aa78e2 100644
--- a/daemon/fw/forwarder.cpp
+++ b/daemon/fw/forwarder.cpp
@@ -377,8 +377,7 @@
       pitEntry->deleteOutRecord(ingress.face);
     }
 
-    // foreach pending downstream
-    for (const auto& pendingDownstream : pendingDownstreams) {
+    for (Face* pendingDownstream : pendingDownstreams) {
       if (pendingDownstream->getId() == ingress.face.getId() &&
           pendingDownstream->getLinkType() != ndn::nfd::LINK_TYPE_AD_HOC) {
         continue;
@@ -520,7 +519,7 @@
   nackPkt.setHeader(nack);
 
   // erase in-record
-  pitEntry->deleteInRecord(egress);
+  pitEntry->deleteInRecord(inRecord);
 
   // send Nack on face
   egress.sendNack(nackPkt);
diff --git a/daemon/fw/strategy.cpp b/daemon/fw/strategy.cpp
index 10610ad..712e200 100644
--- a/daemon/fw/strategy.cpp
+++ b/daemon/fw/strategy.cpp
@@ -248,20 +248,19 @@
 {
   BOOST_ASSERT(pitEntry->getInterest().matchesData(data));
 
-  shared_ptr<lp::PitToken> pitToken;
   auto inRecord = pitEntry->getInRecord(egress);
   if (inRecord != pitEntry->in_end()) {
-    pitToken = inRecord->getInterest().getTag<lp::PitToken>();
-  }
+    auto pitToken = inRecord->getInterest().getTag<lp::PitToken>();
 
-  // delete the PIT entry's in-record based on egress,
-  // since the Data is sent to the face from which the Interest was received
-  pitEntry->deleteInRecord(egress);
+    // delete the PIT entry's in-record based on egress,
+    // since the Data is sent to the face from which the Interest was received
+    pitEntry->deleteInRecord(inRecord);
 
-  if (pitToken != nullptr) {
-    Data data2 = data; // make a copy so each downstream can get a different PIT token
-    data2.setTag(pitToken);
-    return m_forwarder.onOutgoingData(data2, egress);
+    if (pitToken != nullptr) {
+      Data data2 = data; // make a copy so each downstream can get a different PIT token
+      data2.setTag(pitToken);
+      return m_forwarder.onOutgoingData(data2, egress);
+    }
   }
   return m_forwarder.onOutgoingData(data, egress);
 }