Commit f20af942 authored by Paul's avatar Paul
Browse files

Mark the problems

parent 47bde8f7
...@@ -87,10 +87,14 @@ struct problem_cache ...@@ -87,10 +87,14 @@ struct problem_cache
{ {
cache[create_key(name, problem)] = solution; cache[create_key(name, problem)] = solution;
} }
void mark(const std::string& name, const value& problem)
{
insert(name, problem, value{});
}
optional<value> get(const std::string& name, const value& problem) const optional<value> get(const std::string& name, const value& problem) const
{ {
auto it = cache.find(create_key(name, problem)); auto it = cache.find(create_key(name, problem));
if(it == cache.end()) if (it == cache.end())
return nullopt; return nullopt;
return it->second; return it->second;
} }
...@@ -127,6 +131,7 @@ struct compile_plan ...@@ -127,6 +131,7 @@ struct compile_plan
} }
else else
{ {
pc.mark(preop.name(), problem);
const auto& solutions = config.value().solutions; const auto& solutions = config.value().solutions;
results.resize(solutions.size()); results.resize(solutions.size());
for(auto i : range(solutions.size())) for(auto i : range(solutions.size()))
...@@ -184,7 +189,7 @@ struct compile_manager ...@@ -184,7 +189,7 @@ struct compile_manager
problem_cache pc; problem_cache pc;
std::vector<compile_plan> cps; std::vector<compile_plan> cps;
template <class... Ts> template<class... Ts>
void add_plan(Ts&&... xs) void add_plan(Ts&&... xs)
{ {
cps.push_back({std::forward<Ts>(xs)...}); cps.push_back({std::forward<Ts>(xs)...});
...@@ -213,10 +218,9 @@ struct compile_manager ...@@ -213,10 +218,9 @@ struct compile_manager
} }
// Remove compile_plan already executed // Remove compile_plan already executed
cps.erase(std::remove_if(cps.begin(), cps.erase(std::remove_if(cps.begin(), cps.end(), [](const auto& cp) {
cps.end(), return not cp.results.empty();
[](const auto& cp) { return not cp.results.empty(); }), }), cps.end());
cps.end());
} }
}; };
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment