From 6aa2079079f6534359a2d24ac1641f986df3417a Mon Sep 17 00:00:00 2001 From: Alexandre Duret-Lutz Date: Fri, 10 Sep 2021 11:47:44 +0200 Subject: [PATCH] zlktree: speedup the construction of ACD nodes This uses the foreach_set_index() method introduced in the previous patch to speed up the copy bitvectors in ACD nodes, as pointed in issue #476. Running PREFIXCMD='valgrind --tool=callgrind' ./run python3 -c \ "import spot; spot.acd_transform(spot.automaton('syntcomp_91.hoa'))" went from 65139436227 instruction fetches down to 18490399159. * spot/twaalgos/zlktree.cc (acd::build_): Use foreach_set_index(). --- spot/twaalgos/zlktree.cc | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/spot/twaalgos/zlktree.cc b/spot/twaalgos/zlktree.cc index 6e9f32904..c86c929b5 100644 --- a/spot/twaalgos/zlktree.cc +++ b/spot/twaalgos/zlktree.cc @@ -482,12 +482,11 @@ namespace spot n.parent = node; n.level = lvl + 1; n.scc = scc; - for (unsigned e = 1; e < nedges; ++e) - if (bv->get(e)) - { - n.edges[e] = true; - n.states[aut->edge_storage(e).src] = true; - } + bv->foreach_set_index([&](unsigned e) + { + n.edges[e] = true; + n.states[aut->edge_storage(e).src] = true; + }); } unsigned after_size = nodes_.size(); unsigned children = after_size - before_size;