From 425bcff801905548dbee6ad2b8c053551f7c06d9 Mon Sep 17 00:00:00 2001 From: mio Date: Thu, 10 Oct 2024 21:11:28 +1000 Subject: 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 --- tdeioslave/trash/discspaceutil.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'tdeioslave') 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; } -- cgit v1.2.1