From a308df82ae5d0ea22f3d86ee63138b3df48ab2a9 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Tue, 28 Apr 2020 12:50:20 +0200 Subject: [PATCH] Don't use a QTextStream to write the trash info file Using a QTextStream to write the file is probably around 50 times slower than simply creating the required string here and writing it. Change-Id: Ia848e4ad2688f098c671938d7ad9aaa4764a4158 Reviewed-by: Thiago Macieira Reviewed-by: Alex Blasche --- src/corelib/io/qfilesystemengine_unix.cpp | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/corelib/io/qfilesystemengine_unix.cpp b/src/corelib/io/qfilesystemengine_unix.cpp index 67cff7c68c2..2419a013323 100644 --- a/src/corelib/io/qfilesystemengine_unix.cpp +++ b/src/corelib/io/qfilesystemengine_unix.cpp @@ -43,7 +43,6 @@ #include "qfilesystemengine_p.h" #include "qfile.h" #include "qstorageinfo.h" -#include "qtextstream.h" #include #include @@ -1393,14 +1392,12 @@ bool QFileSystemEngine::moveFileToTrash(const QFileSystemEntry &source, return false; } - QTextStream out(&infoFile); -#if QT_CONFIG(textcodec) - out.setCodec("UTF-8"); -#endif - out << "[Trash Info]" << Qt::endl; - out << "Path=" << sourcePath << Qt::endl; - out << "DeletionDate=" - << QDateTime::currentDateTime().toString(QLatin1String("yyyy-MM-ddThh:mm:ss")) << Qt::endl; + QByteArray info = + "[Trash Info]\n" + "Path=" + sourcePath.toUtf8() + "\n" + "DeletionDate=" + QDateTime::currentDateTime().toString(QLatin1String("yyyy-MM-ddThh:mm:ss")).toUtf8() + + "\n"; + infoFile.write(info); infoFile.close(); newLocation = QFileSystemEntry(targetPath);