Reduce usage of std::bind()
C++14 lambdas are easier to read, easier to debug,
and can usually be better optimized by the compiler.
Change-Id: I294f275904f91942a8de946fe63e77078a7608a6
diff --git a/daemon/face/generic-link-service.cpp b/daemon/face/generic-link-service.cpp
index 819a91a..5ed4ac2 100644
--- a/daemon/face/generic-link-service.cpp
+++ b/daemon/face/generic-link-service.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2020, Regents of the University of California,
+ * Copyright (c) 2014-2021, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -45,11 +45,11 @@
, m_reassembler(m_options.reassemblerOptions, this)
, m_reliability(m_options.reliabilityOptions, this)
, m_lastSeqNo(-2)
- , m_nextMarkTime(time::steady_clock::TimePoint::max())
+ , m_nextMarkTime(time::steady_clock::time_point::max())
, m_nMarkedSinceInMarkingState(0)
{
- m_reassembler.beforeTimeout.connect([this] (auto...) { ++this->nReassemblyTimeouts; });
- m_reliability.onDroppedInterest.connect([this] (const auto& i) { this->notifyDroppedInterest(i); });
+ m_reassembler.beforeTimeout.connect([this] (auto&&...) { ++nReassemblyTimeouts; });
+ m_reliability.onDroppedInterest.connect([this] (const auto& i) { notifyDroppedInterest(i); });
nReassembling.observe(&m_reassembler);
}
@@ -105,7 +105,7 @@
auto block = pkt.wireEncode();
if (mtu != MTU_UNLIMITED && block.size() > static_cast<size_t>(mtu)) {
- ++this->nOutOverMtu;
+ ++nOutOverMtu;
NFD_LOG_FACE_WARN("attempted to send packet over MTU limit");
return;
}
@@ -207,7 +207,7 @@
std::tie(isOk, frags) = m_fragmenter.fragmentPacket(pkt, mtu);
if (!isOk) {
// fragmentation failed (warning is logged by LpFragmenter)
- ++this->nFragmentationErrors;
+ ++nFragmentationErrors;
return;
}
}
@@ -261,7 +261,7 @@
if (static_cast<size_t>(sendQueueLength) > m_options.defaultCongestionThreshold) {
const auto now = time::steady_clock::now();
- if (m_nextMarkTime == time::steady_clock::TimePoint::max()) {
+ if (m_nextMarkTime == time::steady_clock::time_point::max()) {
m_nextMarkTime = now + m_options.baseCongestionMarkingInterval;
}
// Mark packet if sendQueue stays above target for one interval
@@ -279,10 +279,10 @@
m_nextMarkTime += interval;
}
}
- else if (m_nextMarkTime != time::steady_clock::TimePoint::max()) {
+ else if (m_nextMarkTime != time::steady_clock::time_point::max()) {
// Congestion incident has ended, so reset
NFD_LOG_FACE_DEBUG("Send queue length dropped below congestion threshold");
- m_nextMarkTime = time::steady_clock::TimePoint::max();
+ m_nextMarkTime = time::steady_clock::time_point::max();
m_nMarkedSinceInMarkingState = 0;
}
}
@@ -296,7 +296,7 @@
if (m_options.reliabilityOptions.isEnabled) {
if (!m_reliability.processIncomingPacket(pkt)) {
NFD_LOG_FACE_TRACE("received duplicate fragment: DROP");
- ++this->nDuplicateSequence;
+ ++nDuplicateSequence;
return;
}
}
@@ -321,7 +321,7 @@
}
}
catch (const tlv::Error& e) {
- ++this->nInLpInvalid;
+ ++nInLpInvalid;
NFD_LOG_FACE_WARN("packet parse error (" << e.what() << "): DROP");
}
}
@@ -344,13 +344,13 @@
this->decodeData(netPkt, firstPkt, endpointId);
break;
default:
- ++this->nInNetInvalid;
+ ++nInNetInvalid;
NFD_LOG_FACE_WARN("unrecognized network-layer packet TLV-TYPE " << netPkt.type() << ": DROP");
return;
}
}
catch (const tlv::Error& e) {
- ++this->nInNetInvalid;
+ ++nInNetInvalid;
NFD_LOG_FACE_WARN("packet parse error (" << e.what() << "): DROP");
}
}
@@ -376,7 +376,7 @@
}
if (firstPkt.has<lp::CachePolicyField>()) {
- ++this->nInNetInvalid;
+ ++nInNetInvalid;
NFD_LOG_FACE_WARN("received CachePolicy with Interest: DROP");
return;
}
@@ -399,7 +399,7 @@
}
if (firstPkt.has<lp::PrefixAnnouncementField>()) {
- ++this->nInNetInvalid;
+ ++nInNetInvalid;
NFD_LOG_FACE_WARN("received PrefixAnnouncement with Interest: DROP");
return;
}
@@ -421,13 +421,13 @@
auto data = make_shared<Data>(netPkt);
if (firstPkt.has<lp::NackField>()) {
- ++this->nInNetInvalid;
+ ++nInNetInvalid;
NFD_LOG_FACE_WARN("received Nack with Data: DROP");
return;
}
if (firstPkt.has<lp::NextHopFaceIdField>()) {
- ++this->nInNetInvalid;
+ ++nInNetInvalid;
NFD_LOG_FACE_WARN("received NextHopFaceId with Data: DROP");
return;
}
@@ -448,7 +448,7 @@
}
if (firstPkt.has<lp::NonDiscoveryField>()) {
- ++this->nInNetInvalid;
+ ++nInNetInvalid;
NFD_LOG_FACE_WARN("received NonDiscovery with Data: DROP");
return;
}
@@ -476,13 +476,13 @@
nack.setHeader(firstPkt.get<lp::NackField>());
if (firstPkt.has<lp::NextHopFaceIdField>()) {
- ++this->nInNetInvalid;
+ ++nInNetInvalid;
NFD_LOG_FACE_WARN("received NextHopFaceId with Nack: DROP");
return;
}
if (firstPkt.has<lp::CachePolicyField>()) {
- ++this->nInNetInvalid;
+ ++nInNetInvalid;
NFD_LOG_FACE_WARN("received CachePolicy with Nack: DROP");
return;
}
@@ -496,13 +496,13 @@
}
if (firstPkt.has<lp::NonDiscoveryField>()) {
- ++this->nInNetInvalid;
+ ++nInNetInvalid;
NFD_LOG_FACE_WARN("received NonDiscovery with Nack: DROP");
return;
}
if (firstPkt.has<lp::PrefixAnnouncementField>()) {
- ++this->nInNetInvalid;
+ ++nInNetInvalid;
NFD_LOG_FACE_WARN("received PrefixAnnouncement with Nack: DROP");
return;
}