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:
authorOliver Schneider <oliver@assarbad.net>2019-11-17 01:17:18 +0300
committerOliver Schneider <oliver@assarbad.net>2019-11-17 01:17:18 +0300
commitb721da7b9ac1e46055d40b2d0c2763c057858b1d (patch)
tree3881b3935394a58866144053250f87305991a39c
parentc4c75435b9aff78752fb25719b8841209a97d551 (diff)
Remove a call to GetFileAttributesW(), addressing issue #193.
When profiling on Windows 7 this took up ~25% of CPU time, on Windows 10 (1903) it was still nearly 20%. So this should be a cheap win.
-rw-r--r--windirstat/dirstatdoc.cpp7
-rw-r--r--windirstat/item.cpp18
-rw-r--r--windirstat/mountpoints.cpp15
-rw-r--r--windirstat/mountpoints.h1
-rw-r--r--windirstat/windirstat.cpp4
-rw-r--r--windirstat/windirstat.h2
6 files changed, 27 insertions, 20 deletions
diff --git a/windirstat/dirstatdoc.cpp b/windirstat/dirstatdoc.cpp
index 213f913..cf85958 100644
--- a/windirstat/dirstatdoc.cpp
+++ b/windirstat/dirstatdoc.cpp
@@ -694,7 +694,8 @@ void CDirstatDoc::RecurseRefreshMountPointItems(CItem *item)
void CDirstatDoc::RecurseRefreshJunctionItems(CItem *item)
{
- if(IT_DIRECTORY == item->GetType() && item != GetRootItem() && GetWDSApp()->IsFolderJunction(item->GetPath()))
+
+ if(IT_DIRECTORY == item->GetType() && item != GetRootItem() && GetWDSApp()->IsFolderJunction(item->GetAttributes()))
{
RefreshItem(item);
}
@@ -1010,7 +1011,7 @@ void CDirstatDoc::RecursiveUserDefinedCleanup(const USERDEFINEDCLEANUP *udc, con
{
// (Depth first.)
- CFileFind finder;
+ CFileFindWDS finder;
BOOL b = finder.FindFile(currentPath + _T("\\*.*"));
while(b)
{
@@ -1023,7 +1024,7 @@ void CDirstatDoc::RecursiveUserDefinedCleanup(const USERDEFINEDCLEANUP *udc, con
{
continue;
}
- if(GetWDSApp()->IsFolderJunction(finder.GetFilePath()) && !GetOptions()->IsFollowJunctionPoints())
+ if(GetWDSApp()->IsFolderJunction(finder.GetAttributes()) && !GetOptions()->IsFollowJunctionPoints())
{
continue;
}
diff --git a/windirstat/item.cpp b/windirstat/item.cpp
index 20b3582..6c57446 100644
--- a/windirstat/item.cpp
+++ b/windirstat/item.cpp
@@ -390,7 +390,7 @@ int CItem::GetImageToCache() const
{
image = GetMyImageList()->getMountPointImage();
}
- else if(GetType() == IT_DIRECTORY && GetWDSApp()->IsFolderJunction(path))
+ else if(GetType() == IT_DIRECTORY && GetWDSApp()->IsFolderJunction(GetAttributes()))
{
image = GetMyImageList()->getJunctionImage();
}
@@ -1356,7 +1356,7 @@ bool CItem::StartRefresh()
return true;
}
- if(GetType() == IT_DIRECTORY && !IsRootItem() && GetWDSApp()->IsFolderJunction(GetPath()) && !GetOptions()->IsFollowJunctionPoints())
+ if(GetType() == IT_DIRECTORY && !IsRootItem() && GetWDSApp()->IsFolderJunction(GetAttributes()) && !GetOptions()->IsFollowJunctionPoints())
{
return true;
}
@@ -1376,12 +1376,12 @@ bool CItem::StartRefresh()
CreateUnknownItem();
}
}
-
- {
- CWorkLimiter limiter;
- limiter.Start(0);
- DoSomeWork(&limiter);
- }
+
+ {
+ CWorkLimiter limiter;
+ limiter.Start(0);
+ DoSomeWork(&limiter);
+ }
if(wasExpanded)
{
@@ -1846,7 +1846,7 @@ void CItem::AddDirectory(CFileFindWDS& finder)
{
bool dontFollow = GetWDSApp()->IsVolumeMountPoint(finder.GetFilePath()) && !GetOptions()->IsFollowMountPoints();
- dontFollow |= GetWDSApp()->IsFolderJunction(finder.GetFilePath()) && !GetOptions()->IsFollowJunctionPoints();
+ dontFollow |= GetWDSApp()->IsFolderJunction(finder.GetAttributes()) && !GetOptions()->IsFollowJunctionPoints();
CItem *child = new CItem(IT_DIRECTORY, finder.GetFileName(), dontFollow);
FILETIME t;
diff --git a/windirstat/mountpoints.cpp b/windirstat/mountpoints.cpp
index fcd0d05..deebc65 100644
--- a/windirstat/mountpoints.cpp
+++ b/windirstat/mountpoints.cpp
@@ -225,20 +225,25 @@ bool CReparsePoints::IsVolumeMountPoint(CString path)
// Check whether the current item is a junction point but no volume mount point
// as the latter ones are treated differently (see above).
-bool CReparsePoints::IsFolderJunction(CString path)
+bool CReparsePoints::IsFolderJunction(DWORD attr)
{
- if(IsVolumeMountPoint(path))
+ if (attr == INVALID_FILE_ATTRIBUTES)
{
return false;
}
- DWORD attr = ::GetFileAttributes(path);
- if(attr == INVALID_FILE_ATTRIBUTES)
+ return ((attr & FILE_ATTRIBUTE_REPARSE_POINT) != 0);
+}
+
+// ... same as before, but based on the full path
+bool CReparsePoints::IsFolderJunction(CString path)
+{
+ if(IsVolumeMountPoint(path))
{
return false;
}
- return ((attr & FILE_ATTRIBUTE_REPARSE_POINT) != 0);
+ return IsFolderJunction(::GetFileAttributes(path));
}
bool CReparsePoints::IsVolumeMountPoint(CString volume, CString path)
diff --git a/windirstat/mountpoints.h b/windirstat/mountpoints.h
index aee7a7a..f356304 100644
--- a/windirstat/mountpoints.h
+++ b/windirstat/mountpoints.h
@@ -41,6 +41,7 @@ public:
void Initialize();
bool IsVolumeMountPoint(CString path);
bool IsFolderJunction(CString path);
+ bool IsFolderJunction(DWORD attr);
private:
void Clear();
diff --git a/windirstat/windirstat.cpp b/windirstat/windirstat.cpp
index c60ad9f..7bb942f 100644
--- a/windirstat/windirstat.cpp
+++ b/windirstat/windirstat.cpp
@@ -420,9 +420,9 @@ bool CDirstatApp::IsVolumeMountPoint(CString path)
return m_mountPoints.IsVolumeMountPoint(path);
}
-bool CDirstatApp::IsFolderJunction(CString path)
+bool CDirstatApp::IsFolderJunction(DWORD attr)
{
- return m_mountPoints.IsFolderJunction(path);
+ return m_mountPoints.IsFolderJunction(attr);
}
// Get the alternative colors for compressed and encrypted files/folders.
diff --git a/windirstat/windirstat.h b/windirstat/windirstat.h
index 499b98c..507be6d 100644
--- a/windirstat/windirstat.h
+++ b/windirstat/windirstat.h
@@ -71,7 +71,7 @@ public:
void ReReadMountPoints();
bool IsVolumeMountPoint(CString path);
- bool IsFolderJunction(CString path);
+ bool IsFolderJunction(DWORD attr);
COLORREF AltColor(); // Coloring of compressed items
COLORREF AltEncryptionColor(); // Coloring of encrypted items