aboutsummaryrefslogtreecommitdiff
path: root/build2/prerequisite
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2017-01-19 12:45:04 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2017-01-19 12:45:04 +0200
commit5607313a91e5ca0113b1f8b9acfd02c1fb105346 (patch)
treeb14fd2737b88f90e9d142d8e6eff36876e0f8b5a /build2/prerequisite
parent8ecc2d18bf86b1021a31a2e5d01e71afbaa1efd0 (diff)
Get rid of project_name_pool
With small string optimizations this is most likely a hindrance rather that an optimization.
Diffstat (limited to 'build2/prerequisite')
-rw-r--r--build2/prerequisite28
1 files changed, 13 insertions, 15 deletions
diff --git a/build2/prerequisite b/build2/prerequisite
index 1fe3c1a..b259557 100644
--- a/build2/prerequisite
+++ b/build2/prerequisite
@@ -27,22 +27,21 @@ namespace build2
public:
typedef build2::scope scope_type;
- mutable const string* proj; // Can be NULL, from project_name_pool.
- target_key tk; // .dir and .out can be relative.
- mutable scope_type* scope; // Can be NULL if tk.dir is absolute.
+ const optional<string>& proj;
+ target_key tk; // .dir and .out can be relative.
+ mutable scope_type* scope; // Can be NULL if tk.dir is absolute.
template <typename T>
bool is_a () const {return tk.is_a<T> ();}
bool is_a (const target_type& tt) const {return tk.is_a (tt);}
+
+ static const optional<string> nullproj;
};
inline bool
operator== (const prerequisite_key& x, const prerequisite_key& y)
{
assert (x.scope == y.scope);
-
- // Can compare project name pointers since they are from project_name_pool.
- //
return x.proj == y.proj && x.tk == y.tk;
}
@@ -71,9 +70,7 @@ namespace std
size_t
operator() (const build2::prerequisite_key& k) const noexcept
{
- // Can hash project name pointers since they are from project_name_pool.
- //
- return build2::combine_hash (hash<const string*> () (k.proj),
+ return build2::combine_hash (hash<build2::optional<string>> () (k.proj),
hash<build2::target_key> () (k.tk));
}
};
@@ -91,7 +88,7 @@ namespace build2
// Note that unlike targets, for prerequisites an empty out directory
// means undetermined rather than being definitely in the out tree.
//
- const string* const proj; // NULL if not project-qualified.
+ const optional<string> proj;
const target_type_type& type;
const dir_path dir; // Normalized absolute or relative (to scope).
const dir_path out; // Empty, normalized absolute, or relative.
@@ -103,14 +100,14 @@ namespace build2
// a target group.
public:
- prerequisite (const string* p,
+ prerequisite (optional<string> p,
const target_type_type& t,
dir_path d,
dir_path o,
string n,
const string* e,
scope_type& s)
- : proj (p),
+ : proj (move (p)),
type (t),
dir (move (d)),
out (move (o)),
@@ -186,7 +183,7 @@ namespace build2
struct prerequisite_set: std::unordered_set<prerequisite>
{
pair<prerequisite&, bool>
- insert (const string* proj,
+ insert (optional<string> proj,
const target_type&,
dir_path dir,
dir_path out,
@@ -196,9 +193,10 @@ namespace build2
tracer&);
pair<prerequisite&, bool>
- insert (const string* proj, const target_key& tk, scope& s, tracer& t)
+ insert (optional<string> proj, const target_key& tk, scope& s, tracer& t)
{
- return insert (proj, *tk.type, *tk.dir, *tk.out, *tk.name, tk.ext, s, t);
+ return insert (
+ move (proj), *tk.type, *tk.dir, *tk.out, *tk.name, tk.ext, s, t);
}
};
}