diff options
author | FPtje <none@none> | 2015-11-05 21:32:18 +0300 |
---|---|---|
committer | FPtje <none@none> | 2015-11-05 21:32:18 +0300 |
commit | 0fdc6a7e4b7d8463a72c9a021ebf8feb7e17a0b9 (patch) | |
tree | 15cb9b7a7a07f036f22eafd832bb39a839d2cc46 /windirstat | |
parent | b97a4a154b3483a6715866e6ef586b28e1e0dda3 (diff) |
Cache extension with a boolean
Diffstat (limited to 'windirstat')
-rw-r--r-- | windirstat/item.cpp | 8 | ||||
-rw-r--r-- | windirstat/item.h | 3 |
2 files changed, 7 insertions, 4 deletions
diff --git a/windirstat/item.cpp b/windirstat/item.cpp index f71f5be..0219fe7 100644 --- a/windirstat/item.cpp +++ b/windirstat/item.cpp @@ -909,7 +909,7 @@ CString CItem::GetName() const CString CItem::GetExtension() const { - if (m_extension != "") + if (m_extension_cached) return m_extension; CString ext; @@ -942,6 +942,7 @@ CString CItem::GetExtension() const } m_extension = ext; + m_extension_cached = true; return ext; } @@ -1610,9 +1611,10 @@ void CItem::RecurseCollectExtensionData(CExtensionData *ed) { GetWDSApp()->PeriodicalUpdateRamUsage(); - if(IsLeaf(GetType())) + auto type = GetType(); + if(IsLeaf(type)) { - if(GetType() == IT_FILE) + if(type == IT_FILE) { CString ext = GetExtension(); SExtensionRecord r; diff --git a/windirstat/item.h b/windirstat/item.h index e9778e9..4bcd4e3 100644 --- a/windirstat/item.h +++ b/windirstat/item.h @@ -62,7 +62,7 @@ enum ITEMTYPE }; // Whether an item type is a leaf type -inline bool IsLeaf(ITEMTYPE t) { return t == IT_FILE || t == IT_FREESPACE || t == IT_UNKNOWN; } +inline bool IsLeaf(ITEMTYPE t) { return ((t == IT_FILE) | (t == IT_FREESPACE) | (t == IT_UNKNOWN)); } // Compare FILETIMEs inline bool operator< (const FILETIME& t1, const FILETIME& t2) @@ -222,6 +222,7 @@ private: ITEMTYPE m_type; // Indicates our type. See ITEMTYPE. CString m_name; // Display name mutable CString m_extension; // Cache of extension (it's used often) + mutable bool m_extension_cached = false; ULONGLONG m_size; // OwnSize, if IT_FILE or IT_FREESPACE, or IT_UNKNOWN; SubtreeTotal else. ULONGLONG m_files; // # Files in subtree ULONGLONG m_subdirs; // # Folder in subtree |