From aa2e525e4a0ca652f6d51d362974ac0ff459c9f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Chocholat=C3=BD?= Date: Fri, 12 Jul 2024 10:49:57 +0200 Subject: [PATCH] fix: Use pointers to key-value pair in unordered map References and pointers do not get invalidated when rehashing of the unordered map happens. This does not hold for iterators, however. --- src/nfa/operations.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/nfa/operations.cc b/src/nfa/operations.cc index 82f2fa70f..171926dbd 100644 --- a/src/nfa/operations.cc +++ b/src/nfa/operations.cc @@ -1222,7 +1222,7 @@ std::optional Nfa::get_word(const Symbol first_epsilon) const { std::optional Nfa::get_word_from_complement(const Alphabet* alphabet) const { if (are_disjoint(initial, final)) { return Word{}; } - std::vector::const_iterator> worklist{}; + std::vector::const_pointer> worklist{}; std::unordered_map subset_map{}; const auto subset_map_end{ subset_map.end() }; @@ -1232,7 +1232,7 @@ std::optional Nfa::get_word_from_complement(const Alphabet* alphabet const State new_initial{ nfa_complete.add_state() }; nfa_complete.initial.insert(new_initial); auto subset_map_it{ subset_map.emplace(initial, new_initial).first }; - worklist.emplace_back(subset_map_it); + worklist.emplace_back(subset_map_it.operator->()); using Iterator = mata::utils::OrdVector::const_iterator; SynchronizedExistentialSymbolPostIterator synchronized_iterator{}; @@ -1278,7 +1278,7 @@ std::optional Nfa::get_word_from_complement(const Alphabet* alphabet continue_complementation = false; } subset_map_it = subset_map.emplace(std::move(orig_targets), target_macrostate).first; - worklist.emplace_back(subset_map_it); + worklist.emplace_back(subset_map_it.operator->()); } nfa_complete.delta.add(macrostate, symbol_advanced_to, target_macrostate); } else {