Skip to content

Commit

Permalink
small optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
lrineau committed Jan 28, 2025
1 parent 9fa067c commit 5a1f8cd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ int
main( )
{
Triangulation cdt;
std::cout << "Inserting a grid 5 x 5 of constraints " << std::endl;
std::cout << "Inserting a grid 5 x 5 of 10 intersecting constraints " << std::endl;
for (int i = 1; i < 6; ++i)
cdt.insert_constraint( Point(0,i), Point(6,i));
for (int j = 1; j < 6; ++j)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1211,15 +1211,14 @@ add_Steiner(const T va, const T vb, const T vc){

Context_list* va_vb_cl = sc_iter_va_vb->second;
erase_context(sc_iter_va_vb);
Context_list* va_vc_cl = get_context_list(va,vc);
Context_list* vc_vb_cl = get_context_list(vc,vb);
Context_list*& vc_vb_cl_ref = contexts_of(vc,vb);

bool vc_vb_was_already_a_subconstraint = vc_vb_cl != nullptr;

if(vc_vb_cl == nullptr) {
vc_vb_cl = new Context_list;
if(vc_vb_cl_ref == nullptr) {
vc_vb_cl_ref = new Context_list;
}

Context_list* vc_vb_cl = vc_vb_cl_ref;

for(Context& ctxt : *va_vb_cl) {
Vertex_it pos = ctxt.current();
Vertex_it next_pos = std::next(pos);
Expand All @@ -1246,17 +1245,14 @@ add_Steiner(const T va, const T vb, const T vc){
vc_vb_cl->push_back(vc_vb_ctxt);
}

Context_list*& va_vc_cl = contexts_of(va,vc);
if (va_vc_cl != nullptr) { // (va,vc) was already a subconstraint
va_vc_cl->splice(va_vc_cl->end(), *va_vb_cl);
delete va_vb_cl;
} else {
va_vc_cl = va_vb_cl;
contexts_of(va,vc) = va_vc_cl;
}

if (false == vc_vb_was_already_a_subconstraint) {
contexts_of(vc,vb) = vc_vb_cl;
}
fix_may_share_in_contexts_constraints(*va_vc_cl);
fix_may_share_in_contexts_constraints(*vc_vb_cl);
}
Expand Down

0 comments on commit 5a1f8cd

Please sign in to comment.