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/rib/readvertise/nfd-rib-readvertise-destination.cpp b/daemon/rib/readvertise/nfd-rib-readvertise-destination.cpp
index a76aaed..0592040 100644
--- a/daemon/rib/readvertise/nfd-rib-readvertise-destination.cpp
+++ b/daemon/rib/readvertise/nfd-rib-readvertise-destination.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2019, 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,10 +44,17 @@
, m_commandOptions(options)
, m_controlParameters(parameters)
{
- m_ribInsertConn = rib.afterInsertEntry.connect(
- std::bind(&NfdRibReadvertiseDestination::handleRibInsert, this, _1));
- m_ribEraseConn = rib.afterEraseEntry.connect(
- std::bind(&NfdRibReadvertiseDestination::handleRibErase, this, _1));
+ m_ribInsertConn = rib.afterInsertEntry.connect([this] (const Name& name) {
+ if (name.isPrefixOf(m_commandOptions.getPrefix())) {
+ setAvailability(true);
+ }
+ });
+
+ m_ribEraseConn = rib.afterEraseEntry.connect([this] (const Name& name) {
+ if (name.isPrefixOf(m_commandOptions.getPrefix())) {
+ setAvailability(false);
+ }
+ });
}
void
@@ -59,7 +66,7 @@
m_controller.start<ndn::nfd::RibRegisterCommand>(
getControlParameters().setName(rr.prefix),
- [=] (const ControlParameters& cp) { successCb(); },
+ [=] (const ControlParameters&) { successCb(); },
[=] (const ControlResponse& cr) { failureCb(cr.getText()); },
getCommandOptions().setSigningInfo(rr.signer));
}
@@ -73,38 +80,10 @@
m_controller.start<ndn::nfd::RibUnregisterCommand>(
getControlParameters().setName(rr.prefix),
- [=] (const ControlParameters& cp) { successCb(); },
+ [=] (const ControlParameters&) { successCb(); },
[=] (const ControlResponse& cr) { failureCb(cr.getText()); },
getCommandOptions().setSigningInfo(rr.signer));
}
-ndn::nfd::ControlParameters
-NfdRibReadvertiseDestination::getControlParameters()
-{
- return m_controlParameters;
-}
-
-ndn::nfd::CommandOptions
-NfdRibReadvertiseDestination::getCommandOptions()
-{
- return m_commandOptions;
-}
-
-void
-NfdRibReadvertiseDestination::handleRibInsert(const ndn::Name& name)
-{
- if (name.isPrefixOf(m_commandOptions.getPrefix())) {
- setAvailability(true);
- }
-}
-
-void
-NfdRibReadvertiseDestination::handleRibErase(const ndn::Name& name)
-{
- if (name.isPrefixOf(m_commandOptions.getPrefix())) {
- setAvailability(false);
- }
-}
-
} // namespace rib
} // namespace nfd
diff --git a/daemon/rib/readvertise/nfd-rib-readvertise-destination.hpp b/daemon/rib/readvertise/nfd-rib-readvertise-destination.hpp
index 9c5bce6..0f61669 100644
--- a/daemon/rib/readvertise/nfd-rib-readvertise-destination.hpp
+++ b/daemon/rib/readvertise/nfd-rib-readvertise-destination.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2019, 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,8 +45,7 @@
Rib& rib,
const ndn::nfd::CommandOptions& options = ndn::nfd::CommandOptions(),
const ndn::nfd::ControlParameters& parameters =
- ndn::nfd::ControlParameters()
- .setOrigin(ndn::nfd::ROUTE_ORIGIN_CLIENT));
+ ndn::nfd::ControlParameters().setOrigin(ndn::nfd::ROUTE_ORIGIN_CLIENT));
/** \brief add a name prefix into NFD RIB
*/
@@ -64,17 +63,16 @@
protected:
ndn::nfd::ControlParameters
- getControlParameters();
+ getControlParameters() const
+ {
+ return m_controlParameters;
+ }
ndn::nfd::CommandOptions
- getCommandOptions();
-
-private:
- void
- handleRibInsert(const Name& name);
-
- void
- handleRibErase(const Name& name);
+ getCommandOptions() const
+ {
+ return m_commandOptions;
+ }
private:
ndn::nfd::Controller& m_controller;