diff options
author | Lars Knoll <lars.knoll@qt.io> | 2020-04-28 12:50:20 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2020-05-01 18:50:10 +0200 |
commit | a308df82ae5d0ea22f3d86ee63138b3df48ab2a9 (patch) | |
tree | fa340e6dcf6fb6938962bb0012977537f44b27a8 /src/corelib/io/qfilesystemengine_unix.cpp | |
parent | 42d2d70abe9683e2d94e8f3aeab2856c0b39e1d8 (diff) |
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 <thiago.macieira@intel.com>
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
Diffstat (limited to 'src/corelib/io/qfilesystemengine_unix.cpp')
-rw-r--r-- | src/corelib/io/qfilesystemengine_unix.cpp | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/src/corelib/io/qfilesystemengine_unix.cpp b/src/corelib/io/qfilesystemengine_unix.cpp index 67cff7c68c..2419a01332 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 <QtCore/qoperatingsystemversion.h> #include <QtCore/private/qcore_unix_p.h> @@ -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); |