From eb104e162dc3eee37e751ad8925f2b3e314632d3 Mon Sep 17 00:00:00 2001 From: Krasimir Angelov Date: Sat, 18 Mar 2023 10:35:14 +0100 Subject: [PATCH] for the memoisation to be effective we need a custom comparator --- src/runtime/c/pgf/generator.h | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/runtime/c/pgf/generator.h b/src/runtime/c/pgf/generator.h index 976bf677f..3f87bbea1 100644 --- a/src/runtime/c/pgf/generator.h +++ b/src/runtime/c/pgf/generator.h @@ -127,6 +127,19 @@ class PGF_INTERNAL_DECL PgfExhaustiveGenerator : public PgfGenerator, public Pgf typedef std::pair,Scope*> Goal; + class CompareGoal : public std::less { + public: + bool operator() (const Goal &g1, const Goal &g2) const { + int cmp = textcmp(g1.first,g2.first); + if (cmp < 0) + return true; + else if (cmp > 0) + return false; + + return (g1.second < g2.second); + } + }; + struct Result { size_t ref_count; Scope *scope; @@ -154,7 +167,7 @@ class PGF_INTERNAL_DECL PgfExhaustiveGenerator : public PgfGenerator, public Pgf } }; - std::map results; + std::map results; std::priority_queue, CompareState> queue; std::vector scopes;