aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/target.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2020-07-17 15:57:33 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2020-07-17 15:57:33 +0200
commitab4a9ef42e8f1070dcb5d783a5afccd2f685e86d (patch)
tree23c7c9420d313076814d91656b9717fc3dd60b68 /libbuild2/target.cxx
parentb74a1e44cb4478356e4261ce0050de744e42d122 (diff)
Add optimized derive_path_with_extension(), use in file_rule
Diffstat (limited to 'libbuild2/target.cxx')
-rw-r--r--libbuild2/target.cxx29
1 files changed, 19 insertions, 10 deletions
diff --git a/libbuild2/target.cxx b/libbuild2/target.cxx
index 0b67dc3..34f3f72 100644
--- a/libbuild2/target.cxx
+++ b/libbuild2/target.cxx
@@ -678,6 +678,15 @@ namespace build2
const path& path_target::
derive_path (const char* de, const char* np, const char* ns, const char* ee)
{
+ return derive_path_with_extension (derive_extension (de), np, ns, ee);
+ }
+
+ const path& path_target::
+ derive_path_with_extension (const string& e,
+ const char* np,
+ const char* ns,
+ const char* ee)
+ {
path_type p (dir);
if (np == nullptr || np[0] == '\0')
@@ -691,22 +700,22 @@ namespace build2
if (ns != nullptr)
p += ns;
- return derive_path (move (p), de, ee);
+ return derive_path_with_extension (move (p), e, ee);
}
const path& path_target::
derive_path (path_type p, const char* de, const char* ee)
{
- // Derive and add the extension if any.
- //
- {
- const string& e (derive_extension (de));
+ return derive_path_with_extension (move (p), derive_extension (de), ee);
+ }
- if (!e.empty ())
- {
- p += '.';
- p += e;
- }
+ const path& path_target::
+ derive_path_with_extension (path_type p, const string& e, const char* ee)
+ {
+ if (!e.empty ())
+ {
+ p += '.';
+ p += e;
}
if (ee != nullptr)