table: pit::FaceRecord stores Face& instead of shared_ptr
refs #3164
Change-Id: Ib23ab2341a37213fee791f2070f13b76da851d53
diff --git a/daemon/fw/best-route-strategy2.cpp b/daemon/fw/best-route-strategy2.cpp
index df6ca4d..5080d9c 100644
--- a/daemon/fw/best-route-strategy2.cpp
+++ b/daemon/fw/best-route-strategy2.cpp
@@ -195,7 +195,7 @@
const lp::NackHeader* inNack = outR.getIncomingNack();
if (inNack == nullptr) {
++nOutRecordsNotNacked;
- lastFaceNotNacked = outR.getFace().get();
+ lastFaceNotNacked = &outR.getFace();
continue;
}
diff --git a/daemon/fw/forwarder.cpp b/daemon/fw/forwarder.cpp
index 2fbc93c..ff8e451 100644
--- a/daemon/fw/forwarder.cpp
+++ b/daemon/fw/forwarder.cpp
@@ -196,9 +196,8 @@
{
NFD_LOG_DEBUG("onContentStoreMiss interest=" << interest.getName());
- shared_ptr<Face> face = const_pointer_cast<Face>(inFace.shared_from_this());
// insert in-record
- pitEntry->insertOrUpdateInRecord(face, interest);
+ pitEntry->insertOrUpdateInRecord(const_cast<Face&>(inFace), interest);
// set PIT unsatisfy timer
this->setUnsatisfyTimer(pitEntry);
@@ -252,8 +251,8 @@
pit::InRecordCollection::iterator pickedInRecord = std::max_element(
pitEntry->in_begin(), pitEntry->in_end(),
[&outFace] (const pit::InRecord& a, const pit::InRecord& b) {
- bool isOutFaceA = a.getFace().get() == &outFace;
- bool isOutFaceB = b.getFace().get() == &outFace;
+ bool isOutFaceA = &a.getFace() == &outFace;
+ bool isOutFaceB = &b.getFace() == &outFace;
return (isOutFaceA > isOutFaceB) ||
(isOutFaceA == isOutFaceB && a.getLastRenewed() < b.getLastRenewed());
});
@@ -267,7 +266,7 @@
}
// insert out-record
- pitEntry->insertOrUpdateOutRecord(outFace.shared_from_this(), *interest);
+ pitEntry->insertOrUpdateOutRecord(outFace, *interest);
// send Interest
outFace.sendInterest(*interest);
@@ -360,7 +359,7 @@
// remember pending downstreams
for (const pit::InRecord& inRecord : pitEntry->getInRecords()) {
if (inRecord.getExpiry() > now) {
- pendingDownstreams.insert(inRecord.getFace().get());
+ pendingDownstreams.insert(&inRecord.getFace());
}
}
diff --git a/daemon/fw/pit-algorithm.cpp b/daemon/fw/pit-algorithm.cpp
index a9ef7ea..3ff63b8 100644
--- a/daemon/fw/pit-algorithm.cpp
+++ b/daemon/fw/pit-algorithm.cpp
@@ -49,7 +49,7 @@
if (scope_prefix::LOCALHOP.isPrefixOf(pitEntry.getName())) {
// face is non-local, violates localhop scope unless PIT entry has local in-record
return std::none_of(pitEntry.in_begin(), pitEntry.in_end(),
- [] (const pit::InRecord& inRecord) { return inRecord.getFace()->getScope() == ndn::nfd::FACE_SCOPE_LOCAL; });
+ [] (const pit::InRecord& inRecord) { return inRecord.getFace().getScope() == ndn::nfd::FACE_SCOPE_LOCAL; });
}
// Name is not subject to scope control
@@ -63,7 +63,7 @@
bool hasUnexpiredOutRecord = std::any_of(pitEntry.out_begin(), pitEntry.out_end(),
[&face, &now] (const pit::OutRecord& outRecord) {
- return outRecord.getFace().get() == &face && outRecord.getExpiry() >= now;
+ return &outRecord.getFace() == &face && outRecord.getExpiry() >= now;
});
if (hasUnexpiredOutRecord) {
return false;
@@ -71,7 +71,7 @@
bool hasUnexpiredOtherInRecord = std::any_of(pitEntry.in_begin(), pitEntry.in_end(),
[&face, &now] (const pit::InRecord& inRecord) {
- return inRecord.getFace().get() != &face && inRecord.getExpiry() >= now;
+ return &inRecord.getFace() != &face && inRecord.getExpiry() >= now;
});
if (!hasUnexpiredOtherInRecord) {
return false;
@@ -87,7 +87,7 @@
for (const pit::InRecord& inRecord : pitEntry.getInRecords()) {
if (inRecord.getLastNonce() == nonce) {
- if (inRecord.getFace().get() == &face) {
+ if (&inRecord.getFace() == &face) {
dnw |= DUPLICATE_NONCE_IN_SAME;
}
else {
@@ -98,7 +98,7 @@
for (const pit::OutRecord& outRecord : pitEntry.getOutRecords()) {
if (outRecord.getLastNonce() == nonce) {
- if (outRecord.getFace().get() == &face) {
+ if (&outRecord.getFace() == &face) {
dnw |= DUPLICATE_NONCE_OUT_SAME;
}
else {
diff --git a/daemon/fw/strategy.cpp b/daemon/fw/strategy.cpp
index 2a40517..f645369 100644
--- a/daemon/fw/strategy.cpp
+++ b/daemon/fw/strategy.cpp
@@ -75,10 +75,10 @@
// populate downstreams with all downstreams faces
std::unordered_set<const Face*> downstreams;
std::transform(pitEntry->in_begin(), pitEntry->in_end(), std::inserter(downstreams, downstreams.end()),
- [] (const pit::InRecord& inR) { return inR.getFace().get(); });
+ [] (const pit::InRecord& inR) { return &inR.getFace(); });
// delete excluded faces
- // .erase in a loop is more efficient than std::set_difference between that requires sorted range
+ // .erase in a loop is more efficient than std::set_difference because that requires sorted range
for (const Face* exceptFace : exceptFaces) {
downstreams.erase(exceptFace);
}