/* Build a copy that will be stored in the dict */
auto* newRoute = new BypassRoute(gw_src, gw_dst);
- for (auto const& link : link_list_)
- newRoute->links.push_back(link);
+ newRoute->links.insert(newRoute->links.end(), begin(link_list_), end(link_list_));
/* Store it */
bypass_routes_.insert({{src, dst}, newRoute});
* dst
* @endverbatim
*/
-static void find_common_ancestors(NetPoint* src, NetPoint* dst,
+static void find_common_ancestors(const NetPoint* src, const NetPoint* dst,
/* OUT */ NetZoneImpl** common_ancestor, NetZoneImpl** src_ancestor,
NetZoneImpl** dst_ancestor)
{
}
/* PRECONDITION: this is the common ancestor of src and dst */
-bool NetZoneImpl::get_bypass_route(NetPoint* src, NetPoint* dst,
+bool NetZoneImpl::get_bypass_route(const NetPoint* src, const NetPoint* dst,
/* OUT */ std::vector<resource::LinkImpl*>& links, double* latency,
std::unordered_set<NetZoneImpl*>& netzones)
{
if (dst->get_englobing_zone() == this && src->get_englobing_zone() == this) {
if (bypass_routes_.find({src, dst}) != bypass_routes_.end()) {
const BypassRoute* bypassedRoute = bypass_routes_.at({src, dst});
- for (resource::LinkImpl* const& link : bypassedRoute->links) {
- links.push_back(link);
- if (latency)
- *latency += link->get_latency();
- }
+ add_link_latency(links, bypassedRoute->links, latency);
XBT_DEBUG("Found a bypass route from '%s' to '%s' with %zu links", src->get_cname(), dst->get_cname(),
bypassedRoute->links.size());
return true;
src->get_cname(), dst->get_cname(), bypassedRoute->links.size());
if (src != key.first)
get_global_route_with_netzones(src, bypassedRoute->gw_src, links, latency, netzones);
- for (resource::LinkImpl* const& link : bypassedRoute->links) {
- links.push_back(link);
- if (latency)
- *latency += link->get_latency();
- }
+ add_link_latency(links, bypassedRoute->links, latency);
if (dst != key.second)
get_global_route_with_netzones(bypassedRoute->gw_dst, dst, links, latency, netzones);
return true;
return false;
}
-void NetZoneImpl::get_global_route(NetPoint* src, NetPoint* dst,
+void NetZoneImpl::get_global_route(const NetPoint* src, const NetPoint* dst,
/* OUT */ std::vector<resource::LinkImpl*>& links, double* latency)
{
std::unordered_set<NetZoneImpl*> netzones;
get_global_route_with_netzones(src, dst, links, latency, netzones);
}
-void NetZoneImpl::get_global_route_with_netzones(NetPoint* src, NetPoint* dst,
+void NetZoneImpl::get_global_route_with_netzones(const NetPoint* src, const NetPoint* dst,
/* OUT */ std::vector<resource::LinkImpl*>& links, double* latency,
std::unordered_set<NetZoneImpl*>& netzones)
{
if (netpoint == netpoint_)
return this;
- for (auto* children : children_) {
+ for (const auto* children : children_) {
const NetZoneImpl* netzone = children->get_netzone_recursive(netpoint);
if (netzone)
return netzone;
bool NetZoneImpl::is_component_recursive(const NetPoint* netpoint) const
{
/* check direct components */
- for (const auto* elem : vertices_) {
- if (elem == netpoint)
- return true;
- }
+ if (std::any_of(begin(vertices_), end(vertices_), [netpoint](const auto* elem) { return elem == netpoint; }))
+ return true;
+
/* check childrens */
- for (const auto* children : children_) {
- if (children->is_component_recursive(netpoint))
- return true;
- }
- return false;
+ return std::any_of(begin(children_), end(children_),
+ [netpoint](const auto* child) { return child->is_component_recursive(netpoint); });
}
} // namespace routing
} // namespace kernel