From 5607313a91e5ca0113b1f8b9acfd02c1fb105346 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 19 Jan 2017 12:45:04 +0200 Subject: Get rid of project_name_pool With small string optimizations this is most likely a hindrance rather that an optimization. --- build2/name | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'build2/name') diff --git a/build2/name b/build2/name index 3bae2d0..2833a2b 100644 --- a/build2/name +++ b/build2/name @@ -19,9 +19,11 @@ namespace build2 // A name is what we operate on by default. Depending on the context, it can // be interpreted as a target or prerequisite name. A name without a type // and directory can be used to represent any text. A name with directory - // and empty value represents a directory. A name may also be qualified with - // a project. If the project name is empty, then it means the name is in a - // project other than our own (e.g., it is installed). + // and empty value represents a directory. + // + // A name may also be qualified with a project. If the project name is + // empty, then it means the name is in a project other than our own (e.g., + // it is installed). // // A type or project can only be specified if either directory or value are // not empty. @@ -31,7 +33,7 @@ namespace build2 // struct name { - const string* proj = nullptr; // Points to project_name_pool. + optional proj; dir_path dir; string type; string value; @@ -45,16 +47,14 @@ namespace build2 name (dir_path d, string t, string v) : dir (move (d)), type (move (t)), value (move (v)) {} - // The first argument should be from project_name_pool. - // - name (const string* p, dir_path d, string t, string v) - : proj (p), dir (move (d)), type (move (t)), value (move (v)) {} + name (optional p, dir_path d, string t, string v) + : proj (move (p)), dir (move (d)), type (move (t)), value (move (v)) {} bool - qualified () const {return proj != nullptr;} + qualified () const {return proj.has_value ();} bool - unqualified () const {return proj == nullptr;} + unqualified () const {return !qualified ();} bool typed () const {return !type.empty ();} @@ -62,7 +62,7 @@ namespace build2 bool untyped () const {return type.empty ();} - // Note: if dir and value are empty then so should be proj and type. + // Note: if dir and value are empty then there should be no proj or type. // bool empty () const {return dir.empty () && value.empty ();} -- cgit v1.1