- for (int max = 0; max <= max_index && not bypassedRoute; max++) {
- for (int i = 0; i < max && not bypassedRoute; i++) {
- if (i <= max_index_src && max <= max_index_dst) {
- key = {path_src.at(i)->netpoint_, path_dst.at(max)->netpoint_};
- auto bpr = bypass_routes_.find(key);
- if (bpr != bypass_routes_.end()) {
- bypassedRoute = bpr->second;
- }
- }
- if (not bypassedRoute && max <= max_index_src && i <= max_index_dst) {
- key = {path_src.at(max)->netpoint_, path_dst.at(i)->netpoint_};
- auto bpr = bypass_routes_.find(key);
- if (bpr != bypass_routes_.end()) {
- bypassedRoute = bpr->second;
- }
- }
- }
-
- if (not bypassedRoute && max <= max_index_src && max <= max_index_dst) {
- key = {path_src.at(max)->netpoint_, path_dst.at(max)->netpoint_};
+ // Search for a bypass with the given indices. Returns true if found. Initialize variables `bypassedRoute' and `key'.
+ auto lookup = [&bypassedRoute, &key, &path_src, &path_dst, this](unsigned src_index, unsigned dst_index) {
+ if (src_index < path_src.size() && dst_index < path_dst.size()) {
+ key = {path_src[src_index]->netpoint_, path_dst[dst_index]->netpoint_};