diff options
author | FPtje <none@none> | 2015-11-05 21:56:42 +0300 |
---|---|---|
committer | FPtje <none@none> | 2015-11-05 21:56:42 +0300 |
commit | 5a7c950b899948d00e5e0aeab61fd4c517e45906 (patch) | |
tree | d78663fde95831bd46e78a14ac428584f6d13ace | |
parent | 160a305b3a32c943d5eb63a387221c678b2c6f8e (diff) |
Small optimisation in CItem::GetExtension()
The profiler indicates that this function is the end of a hot path in the
visualisation. @assarbad mentioned earlier that CStrings are slow, and with this
commit we confirm that.
-rw-r--r-- | windirstat/item.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/windirstat/item.cpp b/windirstat/item.cpp index e4f188c..89a128e 100644 --- a/windirstat/item.cpp +++ b/windirstat/item.cpp @@ -914,18 +914,22 @@ CString CItem::GetExtension() const CString ext; + CString name = GetName(); + switch (GetType()) { case IT_FILE: { - int i = GetName().ReverseFind(wds::chrDot); + int i = name.ReverseFind(wds::chrDot); if(i == -1) { ext = _T("."); } else { - ext = GetName().Mid(i); + // Faster than name.Mid(i); + LPCTSTR alpha = static_cast<LPCTSTR>(name); + ext = &alpha[i]; } ext.MakeLower(); break; @@ -933,7 +937,7 @@ CString CItem::GetExtension() const case IT_FREESPACE: case IT_UNKNOWN: { - ext = GetName(); + ext = name; } break; |