From 0a57242996ba188e02a98470a25150aeb7887e95 Mon Sep 17 00:00:00 2001 From: Laszlo Papp Date: Sun, 24 Nov 2013 00:10:02 +0000 Subject: 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 Reviewed-by: Denis Shienkov --- src/serialport/qserialportinfo_unix.cpp | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) (limited to 'src/serialport/qserialportinfo_unix.cpp') diff --git a/src/serialport/qserialportinfo_unix.cpp b/src/serialport/qserialportinfo_unix.cpp index 9b90cfa..fc7cd80 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()) { -- cgit v1.2.1