diff --git a/SystemTools.cxx b/SystemTools.cxx index 984ea639739839d3e1d647bc881f36c087b97a95..f8cdcfb4e011f3290d041261ce64da89c87ded7f 100644 --- a/SystemTools.cxx +++ b/SystemTools.cxx @@ -28,6 +28,7 @@ #include <iostream> #include <set> #include <sstream> +#include <utility> #include <vector> // Work-around CMake dependency scanning limitation. This must @@ -464,6 +465,9 @@ class SystemToolsEnvMap : public std::map<std::string, std::string> class SystemToolsStatic { public: +#ifdef _WIN32 + SystemToolsEnvMap EnvMap; +#endif #ifdef __CYGWIN__ SystemToolsTranslationMap Cyg2Win32Map; #endif @@ -513,8 +517,8 @@ const char* SystemTools::GetEnvImpl(const char* key) #if defined(_WIN32) std::string env; if (SystemTools::GetEnv(key, env)) { - std::string& menv = (*SystemTools::EnvMap)[key]; - menv = env; + std::string& menv = SystemTools::Statics->EnvMap[key]; + menv = std::move(env); v = menv.c_str(); } #else @@ -4668,7 +4672,6 @@ static unsigned int SystemToolsManagerCount; SystemToolsTranslationMap* SystemTools::TranslationMap; #ifdef _WIN32 SystemToolsPathCaseMap* SystemTools::PathCaseMap; -SystemToolsEnvMap* SystemTools::EnvMap; #endif SystemToolsStatic* SystemTools::Statics; @@ -4716,7 +4719,6 @@ void SystemTools::ClassInitialize() SystemTools::TranslationMap = new SystemToolsTranslationMap; #ifdef _WIN32 SystemTools::PathCaseMap = new SystemToolsPathCaseMap; - SystemTools::EnvMap = new SystemToolsEnvMap; #endif // Create statics singleton instance SystemTools::Statics = new SystemToolsStatic; @@ -4770,7 +4772,6 @@ void SystemTools::ClassFinalize() delete SystemTools::TranslationMap; #ifdef _WIN32 delete SystemTools::PathCaseMap; - delete SystemTools::EnvMap; #endif delete SystemTools::Statics; } diff --git a/SystemTools.hxx.in b/SystemTools.hxx.in index 94fd8508d302e8203afbe3facc81b01c7085854a..0b5c9b67ed0a1240b011ad5b5e9d6ae258ba2a74 100644 --- a/SystemTools.hxx.in +++ b/SystemTools.hxx.in @@ -43,7 +43,6 @@ namespace @KWSYS_NAMESPACE@ { class SystemToolsTranslationMap; class SystemToolsPathCaseMap; -class SystemToolsEnvMap; class SystemToolsStatic; /** \class SystemToolsManager @@ -998,7 +997,6 @@ private: #ifdef _WIN32 static std::string GetActualCaseForPathCached(std::string const& path); static SystemToolsPathCaseMap* PathCaseMap; - static SystemToolsEnvMap* EnvMap; #endif static SystemToolsStatic* Statics; friend class SystemToolsManager;