diff options
Diffstat (limited to 'src/corelib/io')
-rw-r--r-- | src/corelib/io/qlockfile_unix.cpp | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/src/corelib/io/qlockfile_unix.cpp b/src/corelib/io/qlockfile_unix.cpp index de21ee217a..dc8817706c 100644 --- a/src/corelib/io/qlockfile_unix.cpp +++ b/src/corelib/io/qlockfile_unix.cpp @@ -142,13 +142,10 @@ QLockFile::LockError QLockFilePrivate::tryLock_sys() { // Assemble data, to write in a single call to write // (otherwise we'd have to check every write call) - QByteArray fileData; - fileData += QByteArray::number(QCoreApplication::applicationPid()); - fileData += '\n'; - fileData += qAppName().toUtf8(); - fileData += '\n'; - fileData += localHostName().toUtf8(); - fileData += '\n'; + // Use operator% from the fast builder to avoid multiple memory allocations. + QByteArray fileData = QByteArray::number(QCoreApplication::applicationPid()) % '\n' + % qAppName().toUtf8() % '\n' + % localHostName().toUtf8() % '\n'; const QByteArray lockFileName = QFile::encodeName(fileName); const int fd = qt_safe_open(lockFileName.constData(), O_WRONLY | O_CREAT | O_EXCL, 0644); |