diff --git a/hecl/include/hecl/hecl.hpp b/hecl/include/hecl/hecl.hpp index dee1601ab..aa3c1c9b6 100644 --- a/hecl/include/hecl/hecl.hpp +++ b/hecl/include/hecl/hecl.hpp @@ -773,6 +773,23 @@ class ProjectPath std::string m_utf8RelPath; std::string m_utf8AuxInfo; #endif + void ComputeHash() + { +#if HECL_UCS2 + m_utf8AbsPath = WideToUTF8(m_absPath); + m_utf8RelPath = WideToUTF8(m_relPath); + m_utf8AuxInfo = WideToUTF8(m_auxInfo); + if (m_utf8AuxInfo.size()) + m_hash = Hash(m_utf8RelPath + '|' + m_utf8AuxInfo); + else + m_hash = Hash(m_utf8RelPath); +#else + if (m_auxInfo.size()) + m_hash = Hash(m_relPath + '|' + m_auxInfo); + else + m_hash = Hash(m_relPath); +#endif + } public: /** * @brief Empty constructor @@ -866,10 +883,8 @@ public: pp.m_relPath += ext; pp.m_absPath += ext; } -#if HECL_UCS2 - pp.m_utf8AbsPath = WideToUTF8(pp.m_absPath); - pp.m_utf8RelPath = WideToUTF8(pp.m_relPath); -#endif + + pp.ComputeHash(); return pp; } diff --git a/hecl/lib/ProjectPath.cpp b/hecl/lib/ProjectPath.cpp index 75f3f1031..342faee39 100644 --- a/hecl/lib/ProjectPath.cpp +++ b/hecl/lib/ProjectPath.cpp @@ -78,21 +78,8 @@ void ProjectPath::assign(Database::Project& project, const SystemString& path) m_absPath = project.getProjectRootPath().getAbsolutePath() + _S('/') + m_relPath; SanitizePath(m_relPath); SanitizePath(m_absPath); - -#if HECL_UCS2 - m_utf8AbsPath = WideToUTF8(m_absPath); - m_utf8RelPath = WideToUTF8(m_relPath); - m_utf8AuxInfo = WideToUTF8(m_auxInfo); - if (m_utf8AuxInfo.size()) - m_hash = Hash(m_utf8RelPath + '|' + m_utf8AuxInfo); - else - m_hash = Hash(m_utf8RelPath); -#else - if (m_auxInfo.size()) - m_hash = Hash(m_relPath + '|' + m_auxInfo); - else - m_hash = Hash(m_relPath); -#endif + + ComputeHash(); } #if HECL_UCS2 @@ -122,20 +109,7 @@ void ProjectPath::assign(const ProjectPath& parentPath, const SystemString& path SanitizePath(m_relPath); SanitizePath(m_absPath); -#if HECL_UCS2 - m_utf8AbsPath = WideToUTF8(m_absPath); - m_utf8RelPath = WideToUTF8(m_relPath); - m_utf8AuxInfo = WideToUTF8(m_auxInfo); - if (m_utf8AuxInfo.size()) - m_hash = Hash(m_utf8RelPath + '|' + m_utf8AuxInfo); - else - m_hash = Hash(m_utf8RelPath); -#else - if (m_auxInfo.size()) - m_hash = Hash(m_relPath + '|' + m_auxInfo); - else - m_hash = Hash(m_relPath); -#endif + ComputeHash(); } #if HECL_UCS2