summaryrefslogtreecommitdiffstats
path: root/Source/cmAuxSourceDirectoryCommand.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2020-03-26 13:15:02 (GMT)
committerKitware Robot <kwrobot@kitware.com>2020-03-26 13:15:41 (GMT)
commit577fc3ef1942fd11791a4b6cd557b6da32daa5d6 (patch)
tree4ebc154a8be482113f395343df34adb208a238b1 /Source/cmAuxSourceDirectoryCommand.cxx
parent607e790f4b627637a1884af4fc150afa0675c152 (diff)
parentec7928ef266599f1de08b30da84a42d7da3fd6a0 (diff)
downloadCMake-577fc3ef1942fd11791a4b6cd557b6da32daa5d6.zip
CMake-577fc3ef1942fd11791a4b6cd557b6da32daa5d6.tar.gz
CMake-577fc3ef1942fd11791a4b6cd557b6da32daa5d6.tar.bz2
Merge topic 'string-prefix'
ec7928ef26 use _s to construct static string_views at several places 94de927cab VS10Generator: avoid many string allocations 8ca2504a4d use string_views to avoid memory allocations 761f1adcae check for a valid URL scheme before starting to do any splitting ef778d77e0 replace std::string::substr() with operations that do not allocate memory 77616f4681 pass cm::string_view to cmVisualStudioSlnParser::ParseTag() ada6a3226f use cm::string_view for language extension lookups 48adc29721 replace "std::string::find(x) == 0" with cmHasPrefix() ... Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !4501
Diffstat (limited to 'Source/cmAuxSourceDirectoryCommand.cxx')
-rw-r--r--Source/cmAuxSourceDirectoryCommand.cxx7
1 files changed, 4 insertions, 3 deletions
diff --git a/Source/cmAuxSourceDirectoryCommand.cxx b/Source/cmAuxSourceDirectoryCommand.cxx
index 289bb72..d6f7500e 100644
--- a/Source/cmAuxSourceDirectoryCommand.cxx
+++ b/Source/cmAuxSourceDirectoryCommand.cxx
@@ -6,6 +6,8 @@
#include <cstddef>
#include <utility>
+#include <cm/string_view>
+
#include "cmsys/Directory.hxx"
#include "cmExecutionStatus.h"
@@ -50,11 +52,10 @@ bool cmAuxSourceDirectoryCommand(std::vector<std::string> const& args,
// Split the filename into base and extension
std::string::size_type dotpos = file.rfind('.');
if (dotpos != std::string::npos) {
- std::string ext = file.substr(dotpos + 1);
- std::string base = file.substr(0, dotpos);
+ auto ext = cm::string_view(file).substr(dotpos + 1);
// Process only source files
auto cm = mf.GetCMakeInstance();
- if (!base.empty() && cm->IsSourceExtension(ext)) {
+ if (dotpos > 0 && cm->IsSourceExtension(ext)) {
std::string fullname = cmStrCat(templateDirectory, '/', file);
// add the file as a class file so
// depends can be done