From 19c37866524f60a7710b256dd13bf1da9f8cff16 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Sat, 23 Jan 2016 11:12:47 +0200 Subject: Change target_key::ext from pointer to pointer to reference to pointer Probably can also do for the rest of the target_key members. --- build2/search.cxx | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) (limited to 'build2/search.cxx') diff --git a/build2/search.cxx b/build2/search.cxx index 6bb448a..7c27ca5 100644 --- a/build2/search.cxx +++ b/build2/search.cxx @@ -42,7 +42,7 @@ namespace build2 } } - auto i (targets.find (*tk.type, d, *tk.name, *tk.ext, trace)); + auto i (targets.find (*tk.type, d, *tk.name, tk.ext, trace)); if (i == targets.end ()) return 0; @@ -60,20 +60,18 @@ namespace build2 { tracer trace ("search_existing_file"); - prerequisite_key pk (cpk); // Make a copy so we can update extension. - target_key& tk (pk.tk); - assert (tk.dir->relative ()); + const target_key& ctk (cpk.tk); + assert (ctk.dir->relative ()); // Figure out the extension. Pretty similar logic to file::derive_path(). // - const string* ext (*tk.ext); + const string* ext (ctk.ext); if (ext == nullptr) { - if (auto f = tk.type->extension) + if (auto f = ctk.type->extension) { - ext = &f (tk, *pk.scope); // Already from the pool. - tk.ext = &ext; + ext = &f (ctk, *cpk.scope); // Already from the pool. } else { @@ -84,13 +82,19 @@ namespace build2 // explicitly, we will still do so). But let me know what you // think. // - //fail << "no default extension for prerequisite " << pk; + //fail << "no default extension for prerequisite " << cpk; level4 ([&]{trace << "no existing file found for prerequisite " - << pk;}); + << cpk;}); return nullptr; } } + // Make a copy with the updated extension. + // + const prerequisite_key pk { + cpk.proj, target_key {ctk.type, ctk.dir, ctk.name, ext}, cpk.scope}; + const target_key& tk (pk.tk); + // Go over paths looking for a file. // for (const dir_path& d: sp) @@ -159,7 +163,7 @@ namespace build2 // Find or insert. // - auto r (targets.insert (*tk.type, move (d), *tk.name, *tk.ext, trace)); + auto r (targets.insert (*tk.type, move (d), *tk.name, tk.ext, trace)); assert (r.second); target& t (r.first); -- cgit v1.1