From f79817fcf0168c377ea4cb7187830a8caf373168 Mon Sep 17 00:00:00 2001 From: Brad King Date: Sat, 18 Mar 2023 11:19:28 -0400 Subject: cmCxxModuleMapper: Use value semantics in path conversion callback The call site already owns a path it doesn't need when the callback returns. Hand ownership to the callback so it can optionally mutate the path without necessarily allocating. --- Source/cmCxxModuleMapper.cxx | 2 +- Source/cmCxxModuleMapper.h | 2 +- Source/cmGlobalNinjaGenerator.cxx | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Source/cmCxxModuleMapper.cxx b/Source/cmCxxModuleMapper.cxx index 2c57c05..59bf4c7 100644 --- a/Source/cmCxxModuleMapper.cxx +++ b/Source/cmCxxModuleMapper.cxx @@ -21,7 +21,7 @@ cm::optional CxxModuleLocations::BmiGeneratorPathForModule( std::string const& logical_name) const { if (auto l = this->BmiLocationForModule(logical_name)) { - return this->PathForGenerator(*l); + return this->PathForGenerator(std::move(*l)); } return {}; } diff --git a/Source/cmCxxModuleMapper.h b/Source/cmCxxModuleMapper.h index 9271978..0f453b0 100644 --- a/Source/cmCxxModuleMapper.h +++ b/Source/cmCxxModuleMapper.h @@ -30,7 +30,7 @@ struct CxxModuleLocations std::string RootDirectory; // A function to convert a full path to a path for the generator. - std::function PathForGenerator; + std::function PathForGenerator; // Lookup the BMI location of a logical module name. std::function(std::string const&)> diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index 9db92c0..e739038 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -2629,7 +2629,7 @@ bool cmGlobalNinjaGenerator::WriteDyndepFile( { CxxModuleLocations locs; locs.RootDirectory = "."; - locs.PathForGenerator = [this](std::string const& path) -> std::string { + locs.PathForGenerator = [this](std::string path) -> std::string { return this->ConvertToNinjaPath(path); }; locs.BmiLocationForModule = -- cgit v0.12