From 699e3bc87d1cbb3c2b19ddaf5db37909cb49f47b Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 20 Jan 2017 12:38:06 +0200 Subject: Remove prerequisite caching in scope We don't share them often and those that are shared (e.g., cxx{} in obja/objs{}) are lightweight (SOO). --- build2/prerequisite.cxx | 78 +++++++++++++++++++++---------------------------- 1 file changed, 33 insertions(+), 45 deletions(-) (limited to 'build2/prerequisite.cxx') diff --git a/build2/prerequisite.cxx b/build2/prerequisite.cxx index bcd4123..469bdf9 100644 --- a/build2/prerequisite.cxx +++ b/build2/prerequisite.cxx @@ -5,7 +5,7 @@ #include #include -#include // target_type +#include #include #include @@ -48,53 +48,41 @@ namespace build2 return os << pk.tk; } - // prerequisite_set + // prerequisite // - auto prerequisite_set:: - insert (optional proj, - const target_type& tt, - dir_path dir, - dir_path out, - string name, - optional ext, - scope& s, - tracer& trace) -> pair + prerequisite:: + prerequisite (const prerequisite& p, target_type& w) + : proj (p.proj), + type (p.type), + dir (p.dir), + out (p.out), + name (p.name), + ext (p.ext), + owner (w), + target (nullptr) { - //@@ OPT: would be nice to somehow first check if this prerequisite is - // already in the set before allocating a new instance. Something with - // bounds and insert hints? - - // Find or insert. - // - auto r (emplace (move (proj), - tt, - move (dir), - move (out), - move (name), - ext, // Note: cannot move. - s)); - prerequisite& p (const_cast (*r.first)); - - // Update extension if the existing prerequisite has it unspecified. - // - if (p.ext != ext) - { - l5 ([&]{ - diag_record r (trace); - r << "assuming prerequisite " << p << " is the same as the " - << "one with "; - if (!ext) - r << "unspecified extension"; - else if (ext->empty ()) - r << "no extension"; - else - r << "extension " << *ext; - }); + assert (&w.base_scope () == &p.owner.base_scope ()); + } - if (ext) - const_cast&> (p.ext) = move (ext); - } + // Make a prerequisite from a target. + // + prerequisite:: + prerequisite (target_type& t, target_type& w) + : proj (nullopt), + type (t.type ()), + dir (t.dir), + out (t.out), // @@ If it's empty, then we treat as undetermined? + name (t.name), + ext (t.ext), + owner (w), + target (&t) + { + } - return pair (p, r.second); + prerequisite_key prerequisite:: + key () const + { + return prerequisite_key { + proj, {&type, &dir, &out, &name, ext}, &owner.base_scope ()}; } } -- cgit v1.1