aboutsummaryrefslogtreecommitdiff
path: root/build2/prerequisite.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2017-01-20 12:38:06 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2017-01-20 12:38:06 +0200
commit699e3bc87d1cbb3c2b19ddaf5db37909cb49f47b (patch)
treea79a11758bfd58b38a14459e1b268843d14ca67e /build2/prerequisite.cxx
parentea8f6e4aeb120117c72b87da398eeebb35fe192a (diff)
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).
Diffstat (limited to 'build2/prerequisite.cxx')
-rw-r--r--build2/prerequisite.cxx78
1 files changed, 33 insertions, 45 deletions
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 <build2/prerequisite>
#include <build2/scope>
-#include <build2/target> // target_type
+#include <build2/target>
#include <build2/context>
#include <build2/diagnostics>
@@ -48,53 +48,41 @@ namespace build2
return os << pk.tk;
}
- // prerequisite_set
+ // prerequisite
//
- auto prerequisite_set::
- insert (optional<string> proj,
- const target_type& tt,
- dir_path dir,
- dir_path out,
- string name,
- optional<string> ext,
- scope& s,
- tracer& trace) -> pair<prerequisite&, bool>
+ 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<prerequisite&> (*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<optional<string>&> (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<prerequisite&, bool> (p, r.second);
+ prerequisite_key prerequisite::
+ key () const
+ {
+ return prerequisite_key {
+ proj, {&type, &dir, &out, &name, ext}, &owner.base_scope ()};
}
}