Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/windirstat/windirstat.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFPtje <none@none>2015-11-05 21:31:08 +0300
committerFPtje <none@none>2015-11-05 21:31:08 +0300
commitb97a4a154b3483a6715866e6ef586b28e1e0dda3 (patch)
tree53f48ef041ff909b7315e21873b9b24e6a480a76 /windirstat
parent72d95e978d2fcd4b560b70e5697cbd0920a53640 (diff)
Cache the file extension of files
Small optimisation, prevents it from having to be calculated often.
Diffstat (limited to 'windirstat')
-rw-r--r--windirstat/item.cpp5
-rw-r--r--windirstat/item.h1
2 files changed, 6 insertions, 0 deletions
diff --git a/windirstat/item.cpp b/windirstat/item.cpp
index ef15071..f71f5be 100644
--- a/windirstat/item.cpp
+++ b/windirstat/item.cpp
@@ -909,6 +909,9 @@ CString CItem::GetName() const
CString CItem::GetExtension() const
{
+ if (m_extension != "")
+ return m_extension;
+
CString ext;
switch (GetType())
@@ -938,6 +941,8 @@ CString CItem::GetExtension() const
ASSERT(0);
}
+ m_extension = ext;
+
return ext;
}
diff --git a/windirstat/item.h b/windirstat/item.h
index e6e748f..e9778e9 100644
--- a/windirstat/item.h
+++ b/windirstat/item.h
@@ -221,6 +221,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)
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