mirror of
https://github.com/Kitware/CMake.git
synced 2025-10-19 02:17:27 +08:00
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.
This commit is contained in:
@@ -21,7 +21,7 @@ cm::optional<std::string> CxxModuleLocations::BmiGeneratorPathForModule(
|
|||||||
std::string const& logical_name) const
|
std::string const& logical_name) const
|
||||||
{
|
{
|
||||||
if (auto l = this->BmiLocationForModule(logical_name)) {
|
if (auto l = this->BmiLocationForModule(logical_name)) {
|
||||||
return this->PathForGenerator(*l);
|
return this->PathForGenerator(std::move(*l));
|
||||||
}
|
}
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
@@ -30,7 +30,7 @@ struct CxxModuleLocations
|
|||||||
std::string RootDirectory;
|
std::string RootDirectory;
|
||||||
|
|
||||||
// A function to convert a full path to a path for the generator.
|
// A function to convert a full path to a path for the generator.
|
||||||
std::function<std::string(std::string const&)> PathForGenerator;
|
std::function<std::string(std::string)> PathForGenerator;
|
||||||
|
|
||||||
// Lookup the BMI location of a logical module name.
|
// Lookup the BMI location of a logical module name.
|
||||||
std::function<cm::optional<std::string>(std::string const&)>
|
std::function<cm::optional<std::string>(std::string const&)>
|
||||||
|
@@ -2629,7 +2629,7 @@ bool cmGlobalNinjaGenerator::WriteDyndepFile(
|
|||||||
{
|
{
|
||||||
CxxModuleLocations locs;
|
CxxModuleLocations locs;
|
||||||
locs.RootDirectory = ".";
|
locs.RootDirectory = ".";
|
||||||
locs.PathForGenerator = [this](std::string const& path) -> std::string {
|
locs.PathForGenerator = [this](std::string path) -> std::string {
|
||||||
return this->ConvertToNinjaPath(path);
|
return this->ConvertToNinjaPath(path);
|
||||||
};
|
};
|
||||||
locs.BmiLocationForModule =
|
locs.BmiLocationForModule =
|
||||||
|
Reference in New Issue
Block a user