OSDN Git Service

PATCH: [ 1213634 ] Don't store two path copies in PathContext
authorKimmo Varis <kimmov@gmail.com>
Sun, 12 Jun 2005 19:24:43 +0000 (19:24 +0000)
committerKimmo Varis <kimmov@gmail.com>
Sun, 12 Jun 2005 19:24:43 +0000 (19:24 +0000)
Src/PathContext.cpp
Src/PathContext.h
Src/readme.txt

index 1ebeb98..3edb452 100644 (file)
 #include "paths.h"
 
 /**
+ * @brief Copy constructor.
+ */
+PathInfo::PathInfo(const PathInfo &pi)
+{
+       m_sPath = pi.m_sPath;
+}
+
+/**
+ * @brief Get path.
+ * @param [in] sbNormalized TRUE if path is wanted in normalized format.
+ */
+CString PathInfo::GetPath(BOOL bNormalized /*= TRUE*/) const
+{ 
+       if (!bNormalized)
+       {
+               if (paths_EndsWithSlash(m_sPath))
+                       return m_sPath + _T("\\");
+               else
+                       return m_sPath;
+       }
+       else
+               return m_sPath;
+}
+
+/**
  * @brief Set path.
  * @param [in] sPath New path for item.
  */
 void PathInfo::SetPath(CString sPath)
 {
        m_sPath = sPath;
-       m_sNormalizedPath = sPath;
 }
 
 /**
@@ -26,8 +50,7 @@ void PathInfo::SetPath(CString sPath)
  */
 void PathInfo::NormalizePath()
 {
-       m_sNormalizedPath = m_sPath;
-       paths_normalize(m_sNormalizedPath);
+       paths_normalize(m_sPath);
 }
 
 PathContext::PathContext()
@@ -45,7 +68,7 @@ PathContext::PathContext(CString sLeft, CString sRight)
  * @brief Return left path.
  * @param [in] sNormalized If TRUE normalized path is returned.
  */
-const CString& PathContext::GetLeft(BOOL bNormalized) const
+CString PathContext::GetLeft(BOOL bNormalized) const
 {
        return m_pathLeft.GetPath(bNormalized);
 }
@@ -54,7 +77,7 @@ const CString& PathContext::GetLeft(BOOL bNormalized) const
  * @brief Return right path.
  * @param [in] sNormalized If TRUE normalized path is returned.
  */
-const CString& PathContext::GetRight(BOOL bNormalized) const
+CString PathContext::GetRight(BOOL bNormalized) const
 {
        return m_pathRight.GetPath(bNormalized);
 }
index ab956c8..1a9ec0d 100644 (file)
 
 /**
  * @brief Information for one path.
+ *
+ * Path is stored in normalized format (no trailing slash).
  */
 class PathInfo
 {
 public:
        PathInfo() {}
+       PathInfo(const PathInfo &pi);
 
-       const CString & GetPath(BOOL bNormalized = TRUE) const
-               { return (bNormalized ? m_sNormalizedPath : m_sPath); }
+       CString GetPath(BOOL bNormalized = TRUE) const;
        void SetPath(CString path);
        void NormalizePath();
 
 private:
        CString m_sPath;  /**< Directory / file path */
-       CString m_sNormalizedPath; /**< Normalized version of m_sPath (preferred)*/
 };
 
 /**
@@ -36,8 +37,8 @@ class PathContext
 public:
        PathContext();
        PathContext(CString sLeft, CString sRight);
-       const CString & GetLeft(BOOL bNormalized = TRUE) const;
-       const CString & GetRight(BOOL bNormalized = TRUE) const;
+       CString GetLeft(BOOL bNormalized = TRUE) const;
+       CString GetRight(BOOL bNormalized = TRUE) const;
        void SetLeft(LPCTSTR path);
        void SetRight(LPCTSTR path);
 
index 5b354d0..68b13af 100644 (file)
@@ -1,6 +1,8 @@
 2005-06-12 Kimmo
  BUG: [ 1218133 ] German options dialog is to wide
   Src/Languages/German: MergeGerman.rc
+ PATCH: [ 1213634 ] Don't store two path copies in PathContext
+  Src: PathContext.cpp PathContext.h
 
 2005-06-11 Tim
  BUG: [ 1218096 ] Options: 'Line Diff Coloring' frame don't fit