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/fw/algorithm.cpp b/daemon/fw/algorithm.cpp
index a5d692f..a4d864b 100644
--- a/daemon/fw/algorithm.cpp
+++ b/daemon/fw/algorithm.cpp
@@ -84,7 +84,7 @@
bool
hasPendingOutRecords(const pit::Entry& pitEntry)
{
- time::steady_clock::TimePoint now = time::steady_clock::now();
+ auto now = time::steady_clock::now();
return std::any_of(pitEntry.out_begin(), pitEntry.out_end(),
[&now] (const pit::OutRecord& outRecord) {
return outRecord.getExpiry() >= now &&
@@ -92,7 +92,7 @@
});
}
-time::steady_clock::TimePoint
+time::steady_clock::time_point
getLastOutgoing(const pit::Entry& pitEntry)
{
pit::OutRecordCollection::const_iterator lastOutgoing = std::max_element(
@@ -111,7 +111,7 @@
const shared_ptr<pit::Entry>& pitEntry)
{
auto found = nexthops.end();
- auto earliestRenewed = time::steady_clock::TimePoint::max();
+ auto earliestRenewed = time::steady_clock::time_point::max();
for (auto it = nexthops.begin(); it != nexthops.end(); ++it) {
if (!isNextHopEligible(inFace, interest, *it, pitEntry))
@@ -132,7 +132,7 @@
const fib::NextHop& nexthop,
const shared_ptr<pit::Entry>& pitEntry,
bool wantUnused,
- time::steady_clock::TimePoint now)
+ time::steady_clock::time_point now)
{
const Face& outFace = nexthop.getFace();
diff --git a/daemon/fw/forwarder.cpp b/daemon/fw/forwarder.cpp
index 3683734..d984f0c 100644
--- a/daemon/fw/forwarder.cpp
+++ b/daemon/fw/forwarder.cpp
@@ -40,7 +40,7 @@
NFD_LOG_INIT(Forwarder);
-const std::string CFGSEC_FORWARDER = "forwarder";
+const std::string CFG_FORWARDER = "forwarder";
static Name
getDefaultStrategyName()
@@ -607,7 +607,9 @@
void
Forwarder::setConfigFile(ConfigFile& configFile)
{
- configFile.addSectionHandler(CFGSEC_FORWARDER, bind(&Forwarder::processConfig, this, _1, _2, _3));
+ configFile.addSectionHandler(CFG_FORWARDER, [this] (auto&&... args) {
+ processConfig(std::forward<decltype(args)>(args)...);
+ });
}
void
@@ -618,10 +620,10 @@
for (const auto& pair : configSection) {
const std::string& key = pair.first;
if (key == "default_hop_limit") {
- config.defaultHopLimit = ConfigFile::parseNumber<uint8_t>(pair, CFGSEC_FORWARDER);
+ config.defaultHopLimit = ConfigFile::parseNumber<uint8_t>(pair, CFG_FORWARDER);
}
else {
- NDN_THROW(ConfigFile::Error("Unrecognized option " + CFGSEC_FORWARDER + "." + key));
+ NDN_THROW(ConfigFile::Error("Unrecognized option " + CFG_FORWARDER + "." + key));
}
}
diff --git a/daemon/fw/retx-suppression-fixed.cpp b/daemon/fw/retx-suppression-fixed.cpp
index dddd742..50ade91 100644
--- a/daemon/fw/retx-suppression-fixed.cpp
+++ b/daemon/fw/retx-suppression-fixed.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2018, 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,
@@ -44,9 +44,9 @@
return RetxSuppressionResult::NEW;
}
- time::steady_clock::TimePoint lastOutgoing = getLastOutgoing(pitEntry);
- time::steady_clock::TimePoint now = time::steady_clock::now();
- time::steady_clock::Duration sinceLastOutgoing = now - lastOutgoing;
+ auto lastOutgoing = getLastOutgoing(pitEntry);
+ auto now = time::steady_clock::now();
+ auto sinceLastOutgoing = now - lastOutgoing;
bool shouldSuppress = sinceLastOutgoing < m_minRetxInterval;
return shouldSuppress ? RetxSuppressionResult::SUPPRESS : RetxSuppressionResult::FORWARD;
}
diff --git a/daemon/fw/strategy.cpp b/daemon/fw/strategy.cpp
index 9cfb3be..8762e24 100644
--- a/daemon/fw/strategy.cpp
+++ b/daemon/fw/strategy.cpp
@@ -291,13 +291,13 @@
return fibEntry;
}
- const DelegationList& fh = interest.getForwardingHint();
+ const auto& fh = interest.getForwardingHint();
// Forwarding hint should have been stripped by incoming Interest pipeline when reaching producer region
BOOST_ASSERT(!m_forwarder.getNetworkRegionTable().isInProducerRegion(fh));
const fib::Entry* fibEntry = nullptr;
- for (const Delegation& del : fh) {
- fibEntry = &fib.findLongestPrefixMatch(del.name);
+ for (const auto& delegation : fh) {
+ fibEntry = &fib.findLongestPrefixMatch(delegation.name);
if (fibEntry->hasNextHops()) {
if (fibEntry->getPrefix().size() == 0) {
// in consumer region, return the default route
@@ -305,7 +305,7 @@
}
else {
// in default-free zone, use the first delegation that finds a FIB entry
- NFD_LOG_TRACE("lookupFib delegation=" << del.name << " found=" << fibEntry->getPrefix());
+ NFD_LOG_TRACE("lookupFib delegation=" << delegation.name << " found=" << fibEntry->getPrefix());
}
return *fibEntry;
}