table: simplify PIT with C++11 features
refs #2100
Change-Id: I1159761d9439f0a2ff9f6463f89f39372a696e48
diff --git a/daemon/fw/best-route-strategy2.cpp b/daemon/fw/best-route-strategy2.cpp
index 323bb3d..044f5e9 100644
--- a/daemon/fw/best-route-strategy2.cpp
+++ b/daemon/fw/best-route-strategy2.cpp
@@ -63,7 +63,7 @@
if (wantUnused) {
// NextHop must not have unexpired OutRecord
- pit::OutRecordCollection::const_iterator outRecord = pitEntry->getOutRecord(upstream);
+ pit::OutRecordCollection::const_iterator outRecord = pitEntry->getOutRecord(*upstream);
if (outRecord != pitEntry->getOutRecords().end() &&
outRecord->getExpiry() > now) {
return false;
@@ -92,7 +92,7 @@
for (fib::NextHopList::const_iterator it = nexthops.begin(); it != nexthops.end(); ++it) {
if (!predicate_NextHop_eligible(pitEntry, *it, currentDownstream))
continue;
- pit::OutRecordCollection::const_iterator outRecord = pitEntry->getOutRecord(it->getFace());
+ pit::OutRecordCollection::const_iterator outRecord = pitEntry->getOutRecord(*it->getFace());
BOOST_ASSERT(outRecord != pitEntry->getOutRecords().end());
if (outRecord->getLastRenewed() < earliestRenewed) {
found = it;
diff --git a/daemon/fw/forwarder.cpp b/daemon/fw/forwarder.cpp
index d8bc19f..1cd1d16 100644
--- a/daemon/fw/forwarder.cpp
+++ b/daemon/fw/forwarder.cpp
@@ -260,8 +260,8 @@
}
// PIT match
- shared_ptr<pit::DataMatchResult> pitMatches = m_pit.findAllDataMatches(data);
- if (pitMatches->begin() == pitMatches->end()) {
+ pit::DataMatchResult pitMatches = m_pit.findAllDataMatches(data);
+ if (pitMatches.begin() == pitMatches.end()) {
// goto Data unsolicited pipeline
this->onDataUnsolicited(inFace, data);
return;
@@ -272,9 +272,7 @@
std::set<shared_ptr<Face> > pendingDownstreams;
// foreach PitEntry
- for (pit::DataMatchResult::iterator it = pitMatches->begin();
- it != pitMatches->end(); ++it) {
- shared_ptr<pit::Entry> pitEntry = *it;
+ for (const shared_ptr<pit::Entry>& pitEntry : pitMatches) {
NFD_LOG_DEBUG("onIncomingData matching=" << pitEntry->getName());
// cancel unsatisfy & straggler timer
@@ -298,7 +296,7 @@
// mark PIT satisfied
pitEntry->deleteInRecords();
- pitEntry->deleteOutRecord(inFace.shared_from_this());
+ pitEntry->deleteOutRecord(inFace);
// set PIT straggler timer
this->setStragglerTimer(pitEntry, true, data.getFreshnessPeriod());
@@ -437,8 +435,7 @@
}
else {
// insert outgoing Nonce of a specific face
- pit::OutRecordCollection::const_iterator outRecord =
- pitEntry.getOutRecord(upstream->shared_from_this());
+ pit::OutRecordCollection::const_iterator outRecord = pitEntry.getOutRecord(*upstream);
if (outRecord != pitEntry.getOutRecords().end()) {
m_deadNonceList.add(pitEntry.getName(), outRecord->getLastNonce());
}