cmGlobalGenerator: Use transparent comparator to avoid string copies

This commit is contained in:
John Franklin Rickard
2026-02-06 12:27:13 -05:00
committed by Brad King
parent 9a575a835f
commit 6ed75b1fe6
2 changed files with 9 additions and 0 deletions
+4
View File
@@ -1111,7 +1111,11 @@ std::string cmGlobalGenerator::GetLanguageFromExtension(
if (ext.front() == '.') {
ext = ext.substr(1);
}
#if __cplusplus >= 201402L || defined(_MSVC_LANG) && _MSVC_LANG >= 201402L
auto const it = this->ExtensionToLanguage.find(ext);
#else
auto const it = this->ExtensionToLanguage.find(std::string(ext));
#endif
if (it != this->ExtensionToLanguage.end()) {
return it->second;
}
+5
View File
@@ -5,6 +5,7 @@
#include "cmConfigure.h" // IWYU pragma: keep
#include <cstddef>
#include <functional>
#include <iosfwd>
#include <map>
#include <memory>
@@ -872,7 +873,11 @@ private:
std::set<std::string> LanguagesInProgress;
std::map<std::string, std::string> OutputExtensions;
std::map<std::string, std::string> LanguageToOutputExtension;
#if __cplusplus >= 201402L || defined(_MSVC_LANG) && _MSVC_LANG >= 201402L
std::map<std::string, std::string, std::less<void>> ExtensionToLanguage;
#else
std::map<std::string, std::string> ExtensionToLanguage;
#endif
std::map<std::string, int> LanguageToLinkerPreference;
#if !defined(CMAKE_BOOTSTRAP)