From ab4a9ef42e8f1070dcb5d783a5afccd2f685e86d Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 17 Jul 2020 15:57:33 +0200 Subject: Add optimized derive_path_with_extension(), use in file_rule --- libbuild2/target.cxx | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) (limited to 'libbuild2/target.cxx') 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) -- cgit v1.1