Skip to content

Commit 0fe8e85

Browse files
committed
dont trigger segfaults
Signed-off-by: Martijn Govers <Martijn.Govers@Alliander.com>
1 parent c32fda3 commit 0fe8e85

1 file changed

Lines changed: 5 additions & 9 deletions

File tree

  • power_grid_model_c/power_grid_model/include/power_grid_model

power_grid_model_c/power_grid_model/include/power_grid_model/topology.hpp

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ class Topology {
353353
return math_idx.pos;
354354
};
355355
// k as branch number for 2-way branch
356-
for (auto const& [idx, branch_node_idx, branch_connected] :
356+
for (auto&& [idx, branch_node_idx, branch_connected] :
357357
std::views::zip(std::views::iota(0), comp_topo_.branch_node_idx, comp_conn_.branch_connected)) {
358358
assert(std::ssize(branch_connected) == 2); // NOSONAR(R354)
359359

@@ -386,7 +386,7 @@ class Topology {
386386
// set branch idx in coupling
387387
comp_coup_.branch[idx] = Idx2D{.group = math_group, .pos = branch_pos};
388388
}
389-
for (auto const& [idx, branch_node_idx, branch_connected] :
389+
for (auto&& [idx, branch_node_idx, branch_connected] :
390390
std::views::zip(std::views::iota(0), comp_topo_.branch_node_idx, comp_conn_.branch_connected)) {
391391
assert(std::ssize(branch_connected) == 2); // NOSONAR(R354)
392392

@@ -410,17 +410,13 @@ class Topology {
410410
}
411411
assert(i_status || j_status);
412412
// get and set branch idx in math model
413-
BranchIdx const branch_idx{get_group_pos_if(math_group, i_status, i_math),
413+
[[maybe_unused]] BranchIdx const branch_idx{get_group_pos_if(math_group, i_status, i_math),
414414
get_group_pos_if(math_group, j_status, j_math)};
415415
// current branch position index in math model
416-
auto const branch_pos = math_topology_[math_group].n_branch();
417-
// push back
418-
math_topology_[math_group].branch_bus_idx.push_back(branch_idx);
419-
// set branch idx in coupling
420-
comp_coup_.branch[idx] = Idx2D{.group = math_group, .pos = branch_pos};
416+
[[maybe_unused]] auto const branch_pos = math_topology_[math_group].n_branch();
421417
}
422418
// k as branch number for 3-way branch
423-
for (auto const& [idx, i, i_status, j_math] :
419+
for (auto&& [idx, i, i_status, j_math] :
424420
std::views::zip(std::views::iota(0), comp_topo_.branch3_node_idx, comp_conn_.branch3_connected,
425421
std::views::drop(comp_coup_.node, comp_topo_.n_node))) {
426422
std::array<Idx2D, 3> const i_math{

0 commit comments

Comments
 (0)