mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-05 21:31:08 -06:00
cmStringAlgorithms: Add faster cmJoin overloads for strings
cmJoin() is often used with std::string ranges. Generic implementation uses std::ostringstream which is not optimal. With strings we can avoid operator<<() and make much faster implementation. Additional 'initial' argument is useful for cmStringCommand.cxx:HandleAppendCommand().
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
#include <memory>
|
||||
|
||||
#include <cm/iterator>
|
||||
#include <cm/string_view>
|
||||
#include <cmext/string_view>
|
||||
|
||||
#include "cmsys/RegularExpression.hxx"
|
||||
@@ -534,11 +535,14 @@ bool HandleAppendCommand(std::vector<std::string> const& args,
|
||||
return true;
|
||||
}
|
||||
|
||||
const std::string& variable = args[1];
|
||||
auto const& variableName = args[1];
|
||||
|
||||
cm::string_view oldView{ status.GetMakefile().GetSafeDefinition(
|
||||
variableName) };
|
||||
|
||||
auto const newValue = cmJoin(cmMakeRange(args).advance(2), {}, oldView);
|
||||
status.GetMakefile().AddDefinition(variableName, newValue);
|
||||
|
||||
std::string value = status.GetMakefile().GetSafeDefinition(variable);
|
||||
value += cmJoin(cmMakeRange(args).advance(2), std::string());
|
||||
status.GetMakefile().AddDefinition(variable, value);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user