summaryrefslogtreecommitdiffstats
path: root/Source/cmake.cxx
diff options
context:
space:
mode:
authorRolf Eike Beer <eike@sf-mail.de>2020-03-20 19:30:44 (GMT)
committerRolf Eike Beer <eike@sf-mail.de>2020-03-23 21:41:43 (GMT)
commitada6a3226f678df8cc83b752c06c404336718f43 (patch)
treeabe5a5b8ceb6cc3f565751c02bed04b418f79780 /Source/cmake.cxx
parent48adc297211181a97fab75ef0260fda5147c1195 (diff)
downloadCMake-ada6a3226f678df8cc83b752c06c404336718f43.zip
CMake-ada6a3226f678df8cc83b752c06c404336718f43.tar.gz
CMake-ada6a3226f678df8cc83b752c06c404336718f43.tar.bz2
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/cmake.cxx')
-rw-r--r--Source/cmake.cxx5
1 files changed, 3 insertions, 2 deletions
diff --git a/Source/cmake.cxx b/Source/cmake.cxx
index d0a0593..4be4820 100644
--- a/Source/cmake.cxx
+++ b/Source/cmake.cxx
@@ -1978,9 +1978,10 @@ std::string cmake::StripExtension(const std::string& file) const
{
auto dotpos = file.rfind('.');
if (dotpos != std::string::npos) {
- auto ext = file.substr(dotpos + 1);
#if defined(_WIN32) || defined(__APPLE__)
- ext = cmSystemTools::LowerCase(ext);
+ auto ext = cmSystemTools::LowerCase(file.substr(dotpos + 1));
+#else
+ auto ext = cm::string_view(file).substr(dotpos + 1);
#endif
if (this->IsSourceExtension(ext) || this->IsHeaderExtension(ext)) {
return file.substr(0, dotpos);