summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormio <stigma@disroot.org>2024-10-10 21:11:28 +1000
committerMichele Calgaro <michele.calgaro@yahoo.it>2024-10-28 09:03:21 +0900
commit01b4e6da6f81bd341d54a49f609e77ff74fdad16 (patch)
tree20b340f28bdac46284dbd9c692e0e3c0ad01af09
parentd32b065fd0905f06b47c163a4a6d5a33d4989b05 (diff)
downloadtdebase-01b4e6da6f81bd341d54a49f609e77ff74fdad16.tar.gz
tdebase-01b4e6da6f81bd341d54a49f609e77ff74fdad16.zip
Don't stat files twice when sending to trash
TQDir::entryInfoList will call some variation of stat on each file when creating the return list, so there is no need to stat the file again. See: TDE/tdebase#445 Signed-off-by: mio <stigma@disroot.org> (cherry picked from commit 425bcff801905548dbee6ad2b8c053551f7c06d9)
-rw-r--r--tdeioslave/trash/discspaceutil.cpp15
1 files changed, 11 insertions, 4 deletions
diff --git a/tdeioslave/trash/discspaceutil.cpp b/tdeioslave/trash/discspaceutil.cpp
index e231b901c..bca944e39 100644
--- a/tdeioslave/trash/discspaceutil.cpp
+++ b/tdeioslave/trash/discspaceutil.cpp
@@ -52,10 +52,17 @@ unsigned long DiscSpaceUtil::sizeOfPath( const TQString &path )
TQFileInfoListIterator it( *infos );
unsigned long sum = 0;
- TQFileInfo *info = 0;
- while ( (info = it.current()) != 0 ) {
- if ( info->fileName() != "." && info->fileName() != ".." )
- sum += sizeOfPath( info->absFilePath() );
+ const TQFileInfo *info = nullptr;
+ while ((info = it.current()))
+ {
+ if (info->isFile())
+ {
+ sum += info->size();
+ }
+ else if (info->fileName() != "." && info->fileName() != "..")
+ {
+ sum += sizeOfPath(info->absFilePath());
+ }
++it;
}