summaryrefslogtreecommitdiffstats
path: root/Source/cmAddSubDirectoryCommand.cxx
diff options
context:
space:
mode:
authorRolf Eike Beer <eike@sf-mail.de>2020-03-21 11:57:29 (GMT)
committerRolf Eike Beer <eike@sf-mail.de>2020-03-24 16:50:37 (GMT)
commit8ca2504a4d65f433f88ffb79331cea950789152d (patch)
tree82cdd893b2457ab1886bccd3ca9c30361e0bc854 /Source/cmAddSubDirectoryCommand.cxx
parent761f1adcae026c6fd9e10dafdde679adbfaf5869 (diff)
downloadCMake-8ca2504a4d65f433f88ffb79331cea950789152d.zip
CMake-8ca2504a4d65f433f88ffb79331cea950789152d.tar.gz
CMake-8ca2504a4d65f433f88ffb79331cea950789152d.tar.bz2
use string_views to avoid memory allocations
Diffstat (limited to 'Source/cmAddSubDirectoryCommand.cxx')
-rw-r--r--Source/cmAddSubDirectoryCommand.cxx5
1 files changed, 4 insertions, 1 deletions
diff --git a/Source/cmAddSubDirectoryCommand.cxx b/Source/cmAddSubDirectoryCommand.cxx
index 35eabaf..83d6306 100644
--- a/Source/cmAddSubDirectoryCommand.cxx
+++ b/Source/cmAddSubDirectoryCommand.cxx
@@ -4,6 +4,8 @@
#include <cstring>
+#include <cm/string_view>
+
#include "cmExecutionStatus.h"
#include "cmMakefile.h"
#include "cmRange.h"
@@ -86,7 +88,8 @@ bool cmAddSubDirectoryCommand(std::vector<std::string> const& args,
if (binLen > 0 && bin.back() == '/') {
--binLen;
}
- binPath = bin.substr(0, binLen) + srcPath.substr(srcLen);
+ binPath = cmStrCat(cm::string_view(bin).substr(0, binLen),
+ cm::string_view(srcPath).substr(srcLen));
} else {
// Use the binary directory specified.
// Interpret a relative path with respect to the current binary directory.