summaryrefslogtreecommitdiffstats
path: root/src/serialport/qserialportinfo_unix.cpp
diff options
context:
space:
mode:
authorLaszlo Papp <lpapp@kde.org>2013-11-24 00:10:02 +0000
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-11-24 18:50:54 +0100
commit0a57242996ba188e02a98470a25150aeb7887e95 (patch)
treef0736c439c740588166fa341444080023ae32091 /src/serialport/qserialportinfo_unix.cpp
parent516b98aed0abe8c093e90746d0ab3401ad0a59b6 (diff)
Merge two mini-functions for the hard coded list
It is done for the following reason: 1) Consistency with the unix backend of the QSerialPort class, where the serialPortLockFilePath free function is also like this. 2) There is no point in having a separate free function for initializing a variable when it is only used in one place. 3) It is less abstraction. 4) It is negligibly faster. 5) It is still a small enough free function, and naturally fits the one page maximum limit for a function which is the general recommendation in projects. 6) Last, but not least: It also makes the code shorter and more concise. Change-Id: Ie07f06521e11038bdd3cc504a56cadcf00e68269 Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com> Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
Diffstat (limited to 'src/serialport/qserialportinfo_unix.cpp')
-rw-r--r--src/serialport/qserialportinfo_unix.cpp9
1 files changed, 2 insertions, 7 deletions
diff --git a/src/serialport/qserialportinfo_unix.cpp b/src/serialport/qserialportinfo_unix.cpp
index 9b90cfa7..fc7cd80c 100644
--- a/src/serialport/qserialportinfo_unix.cpp
+++ b/src/serialport/qserialportinfo_unix.cpp
@@ -65,7 +65,7 @@ QT_BEGIN_NAMESPACE
#if !defined(LINK_LIBUDEV) && !defined(LOAD_LIBUDEV)
-static inline const QStringList& filtersOfDevices()
+static QStringList filteredDeviceFilePaths()
{
static const QStringList deviceFileNameFilterList = QStringList()
@@ -86,16 +86,11 @@ static inline const QStringList& filtersOfDevices()
; // Here for other *nix OS.
#endif
- return deviceFileNameFilterList;
-}
-
-static QStringList filteredDeviceFilePaths()
-{
QStringList result;
QDir deviceDir(QStringLiteral("/dev"));
if (deviceDir.exists()) {
- deviceDir.setNameFilters(filtersOfDevices());
+ deviceDir.setNameFilters(deviceFileNameFilterList);
deviceDir.setFilter(QDir::Files | QDir::System | QDir::NoSymLinks);
QStringList deviceFilePaths;
foreach (const QFileInfo &deviceFileInfo, deviceDir.entryInfoList()) {