From: Christian Heinrich Date: Thu, 28 Jun 2018 11:10:04 +0000 (+0200) Subject: [SMPI] Colls: Remove that ugly lambda and just use a for-loop X-Git-Tag: v3_21~611 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/4a0779f59324ab426b1005ac8721e980abdd4566 [SMPI] Colls: Remove that ugly lambda and just use a for-loop Merci Arnaud Giersch ;) --- diff --git a/src/smpi/colls/smpi_coll.cpp b/src/smpi/colls/smpi_coll.cpp index b67212c666..114af77f56 100644 --- a/src/smpi/colls/smpi_coll.cpp +++ b/src/smpi/colls/smpi_coll.cpp @@ -98,7 +98,7 @@ void Colls::set_collectives(){ if (selector_name.empty()) selector_name = "default"; - std::map> setter_callbacks = { + std::pair> setter_callbacks[] = { {"gather", &Colls::set_gather}, {"allgather", &Colls::set_allgather}, {"allgatherv", &Colls::set_allgatherv}, {"allreduce", &Colls::set_allreduce}, {"alltoall", &Colls::set_alltoall}, {"alltoallv", &Colls::set_alltoallv}, @@ -106,26 +106,13 @@ void Colls::set_collectives(){ {"scatter", &Colls::set_scatter}, {"bcast", &Colls::set_bcast}, {"barrier", &Colls::set_barrier}}; - // This only prevents code duplication - std::function setup = [selector_name, &setter_callbacks](std::string coll) { - std::string name = simgrid::config::get_value(("smpi/" + coll).c_str()); + for (auto& elem : setter_callbacks) { + std::string name = simgrid::config::get_value(("smpi/" + elem.first).c_str()); if (name.empty()) name = selector_name; - setter_callbacks[coll](name); - }; - - setup("gather"); - setup("allgather"); - setup("allgatherv"); - setup("allreduce"); - setup("alltoall"); - setup("alltoallv"); - setup("reduce"); - setup("reduce_scatter"); - setup("scatter"); - setup("bcast"); - setup("barrier"); + (elem.second)(name); + } }