Skip to content

Commit

Permalink
fix cache for lex_var_comp
Browse files Browse the repository at this point in the history
  • Loading branch information
tklip committed Dec 11, 2024
1 parent 536d5db commit fdd46c0
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/normal_forms.h
Original file line number Diff line number Diff line change
Expand Up @@ -740,17 +740,17 @@ inline void join_paths (std::vector<std::vector<int_t>>& paths) {
// Ordering function for variables from nso formula
template<typename... BAs>
auto lex_var_comp = [](const auto x, const auto y) {
#ifdef CACHE
#ifdef TAU_CACHE
static std::map<std::pair<nso<BAs...>, nso<BAs...>>, bool> cache;
if (auto it = cache.find({x,y}); it != cache.end())
return it->second;
#endif // CACHE
#endif // TAU_CACHE
auto xx = make_string(tau_node_terminal_extractor<BAs...>, x);
auto yy = make_string(tau_node_terminal_extractor<BAs...>, y);
#ifdef CACHE
pair<nso<BAs...>,nso<BAs...>> p (x,y);
#ifdef TAU_CACHE
std::pair<nso<BAs...>,nso<BAs...>> p(x,y);
return cache.emplace(move(p), xx < yy).first->second;
#endif // CACHE
#endif // TAU_CACHE
return xx < yy;
};

Expand Down

0 comments on commit fdd46c0

Please sign in to comment.