summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormio <stigma@disroot.org>2024-10-10 21:11:28 +1000
committermio <stigma@disroot.org>2024-10-12 15:34:58 +1000
commit425bcff801905548dbee6ad2b8c053551f7c06d9 (patch)
treee88c56f86cd0f0a95ab946a0a1e78745691e86c5
parent2b6ca044662284548f3e870ecec450311e1f5aee (diff)
downloadtdebase-425bcff801905548dbee6ad2b8c053551f7c06d9.tar.gz
tdebase-425bcff801905548dbee6ad2b8c053551f7c06d9.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>
-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;
}