summaryrefslogtreecommitdiff
path: root/Source/cmSourceFileLocation.cxx
diff options
context:
space:
mode:
authorRolf Eike Beer <eike@sf-mail.de>2020-03-20 20:30:44 +0100
committerRolf Eike Beer <eike@sf-mail.de>2020-03-23 22:41:43 +0100
commitada6a3226f678df8cc83b752c06c404336718f43 (patch)
treeabe5a5b8ceb6cc3f565751c02bed04b418f79780 /Source/cmSourceFileLocation.cxx
parent48adc297211181a97fab75ef0260fda5147c1195 (diff)
downloadcmake-ada6a3226f678df8cc83b752c06c404336718f43.tar.gz
use cm::string_view for language extension lookups
Once the list of extensions is build the set is just a copy of the vector and not modified anymore. Use a string_view for the members of the set, which saves a small amount of memory. It also makes possible to use string_views as lookup keys, so the callers do not need to create copies for the extensions anymore.
Diffstat (limited to 'Source/cmSourceFileLocation.cxx')
-rw-r--r--Source/cmSourceFileLocation.cxx4
1 files changed, 3 insertions, 1 deletions
diff --git a/Source/cmSourceFileLocation.cxx b/Source/cmSourceFileLocation.cxx
index 5f807b87f1..e852c05bab 100644
--- a/Source/cmSourceFileLocation.cxx
+++ b/Source/cmSourceFileLocation.cxx
@@ -4,6 +4,8 @@
#include <cassert>
+#include <cm/string_view>
+
#include "cmGlobalGenerator.h"
#include "cmMakefile.h"
#include "cmMessageType.h"
@@ -152,7 +154,7 @@ bool cmSourceFileLocation::MatchesAmbiguousExtension(
// Only a fixed set of extensions will be tried to match a file on
// disk. One of these must match if loc refers to this source file.
- std::string const& ext = this->Name.substr(loc.Name.size() + 1);
+ auto ext = cm::string_view(this->Name).substr(loc.Name.size() + 1);
cmMakefile const* mf = this->Makefile;
auto cm = mf->GetCMakeInstance();
return cm->IsSourceExtension(ext) || cm->IsHeaderExtension(ext);