Use new QBA::assign in QStorageInfoPrivate::retrievePosixInfo

QByteArray::assign() re-uses existing unshared capacity(), if any, and
is therefore potentially more efficient than '= QByteArray(~)' (and
never slower).

Task-number: QTBUG-106201
Change-Id: Ic51fc57eb0f84d3624ad3447c93a74241ab3612b
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
(cherry picked from commit b40bb99a60dcccb1dcbb72ac3d3349607d5b3358)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Dennis Oberst 2023-07-31 13:49:31 +02:00 committed by Qt Cherry-pick Bot
parent 48866bb73f
commit cb1489314c

View File

@ -43,9 +43,9 @@ void QStorageInfoPrivate::retrievePosixInfo()
QT_STATFSBUF statfs_buf;
int result = QT_STATFS(QFile::encodeName(rootPath).constData(), &statfs_buf);
if (result == 0) {
device = QByteArray(statfs_buf.f_mntfromname);
device.assign(statfs_buf.f_mntfromname);
readOnly = (statfs_buf.f_flags & MNT_RDONLY) != 0;
fileSystemType = QByteArray(statfs_buf.f_fstypename);
fileSystemType.assign(statfs_buf.f_fstypename);
blockSize = statfs_buf.f_bsize;
}
}