You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
kf5-solid/0002-UDisks-Optimize-severa...

102 lines
3.0 KiB

From 3c0f767f0337fc136976545cb29f89d76a4a5a8c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Stefan=20Br=C3=BCns?= <stefan.bruens@rwth-aachen.de>
Date: Tue, 10 Apr 2018 06:52:58 +0200
Subject: [PATCH 2/5] [UDisks] Optimize several property checks
Summary:
Use QStringLiteral for hasInterface argument
Retrieve MountPoints propery just once when checking mount state.
Test Plan:
make
solid-hardware5 list details
Reviewers: #frameworks, broulik
Reviewed By: broulik
Subscribers: broulik
Tags: #frameworks
Differential Revision: https://phabricator.kde.org/D12123
---
src/solid/devices/backends/udisks2/udisksdevice.cpp | 19 ++++++++++---------
1 file changed, 10 insertions(+), 9 deletions(-)
diff --git a/src/solid/devices/backends/udisks2/udisksdevice.cpp b/src/solid/devices/backends/udisks2/udisksdevice.cpp
index bbdd904..f3fdfff 100644
--- a/src/solid/devices/backends/udisks2/udisksdevice.cpp
+++ b/src/solid/devices/backends/udisks2/udisksdevice.cpp
@@ -780,17 +780,17 @@ Solid::ErrorType Device::errorToSolidError(const QString &error) const
bool Device::isBlock() const
{
- return hasInterface(UD2_DBUS_INTERFACE_BLOCK);
+ return hasInterface(QStringLiteral(UD2_DBUS_INTERFACE_BLOCK));
}
bool Device::isPartition() const
{
- return hasInterface(UD2_DBUS_INTERFACE_PARTITION);
+ return hasInterface(QStringLiteral(UD2_DBUS_INTERFACE_PARTITION));
}
bool Device::isPartitionTable() const
{
- return hasInterface(UD2_DBUS_INTERFACE_PARTITIONTABLE);
+ return hasInterface(QStringLiteral(UD2_DBUS_INTERFACE_PARTITIONTABLE));
}
bool Device::isStorageVolume() const
@@ -800,12 +800,12 @@ bool Device::isStorageVolume() const
bool Device::isStorageAccess() const
{
- return hasInterface(UD2_DBUS_INTERFACE_FILESYSTEM) || isEncryptedContainer();
+ return hasInterface(QStringLiteral(UD2_DBUS_INTERFACE_FILESYSTEM)) || isEncryptedContainer();
}
bool Device::isDrive() const
{
- return hasInterface(UD2_DBUS_INTERFACE_DRIVE);
+ return hasInterface(QStringLiteral(UD2_DBUS_INTERFACE_DRIVE));
}
bool Device::isOpticalDrive() const
@@ -837,12 +837,13 @@ bool Device::mightBeOpticalDisc() const
bool Device::isMounted() const
{
- return propertyExists("MountPoints") && !qdbus_cast<QByteArrayList>(prop("MountPoints")).isEmpty();
+ QVariant mountPoints = prop(QStringLiteral("MountPoints"));
+ return mountPoints.isValid() && !qdbus_cast<QByteArrayList>(mountPoints).isEmpty();
}
bool Device::isEncryptedContainer() const
{
- return hasInterface(UD2_DBUS_INTERFACE_ENCRYPTED);
+ return hasInterface(QStringLiteral(UD2_DBUS_INTERFACE_ENCRYPTED));
}
bool Device::isEncryptedCleartext() const
@@ -857,12 +858,12 @@ bool Device::isEncryptedCleartext() const
bool Device::isSwap() const
{
- return hasInterface(UD2_DBUS_INTERFACE_SWAP);
+ return hasInterface(QStringLiteral(UD2_DBUS_INTERFACE_SWAP));
}
bool Device::isLoop() const
{
- return hasInterface(UD2_DBUS_INTERFACE_LOOP);
+ return hasInterface(QStringLiteral(UD2_DBUS_INTERFACE_LOOP));
}
QString Device::drivePath() const
--
2.14.3