diff options
author | Debao Zhang <hello@debao.me> | 2015-03-26 15:41:50 +0800 |
---|---|---|
committer | Debao Zhang <hello@debao.me> | 2015-03-27 00:44:51 +0000 |
commit | 7f857db22e0d409aac65e4773bb377796893b624 (patch) | |
tree | e342b63a8d03aa030e68e2fbd7d92255a3cd4e8e /src | |
parent | 687dfa9312c1ef4894c32a1966b8ac968110b71e (diff) | |
download | qtserialport-7f857db22e0d409aac65e4773bb377796893b624.tar.gz |
Don't use QStringLiteral when QLatin1String is efficient.
For QLatin1String, startsWith/endsWith/append/operator==/... are overloaded,
so use QLatin1String instead of QStringLiteral in such cases.
Change-Id: Id040697480b7b7f195a2b83bb85ba7e0199d38e3
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/serialport/qserialport_unix.cpp | 2 | ||||
-rw-r--r-- | src/serialport/qserialportinfo_mac.cpp | 8 | ||||
-rw-r--r-- | src/serialport/qserialportinfo_unix.cpp | 14 | ||||
-rw-r--r-- | src/serialport/qserialportinfo_win.cpp | 14 |
4 files changed, 19 insertions, 19 deletions
diff --git a/src/serialport/qserialport_unix.cpp b/src/serialport/qserialport_unix.cpp index 30131ca..7e79763 100644 --- a/src/serialport/qserialport_unix.cpp +++ b/src/serialport/qserialport_unix.cpp @@ -75,7 +75,7 @@ QString serialPortLockFilePath(const QString &portName) QString fileName = portName; fileName.replace(QLatin1Char('/'), QLatin1Char('_')); - fileName.prepend(QStringLiteral("/LCK..")); + fileName.prepend(QLatin1String("/LCK..")); QString lockFilePath; diff --git a/src/serialport/qserialportinfo_mac.cpp b/src/serialport/qserialportinfo_mac.cpp index 6c175f6..558dcbd 100644 --- a/src/serialport/qserialportinfo_mac.cpp +++ b/src/serialport/qserialportinfo_mac.cpp @@ -240,14 +240,14 @@ bool QSerialPortInfo::isValid() const QString QSerialPortInfoPrivate::portNameToSystemLocation(const QString &source) { return (source.startsWith(QLatin1Char('/')) - || source.startsWith(QStringLiteral("./")) - || source.startsWith(QStringLiteral("../"))) - ? source : (QStringLiteral("/dev/") + source); + || source.startsWith(QLatin1String("./")) + || source.startsWith(QLatin1String("../"))) + ? source : (QLatin1String("/dev/") + source); } QString QSerialPortInfoPrivate::portNameFromSystemLocation(const QString &source) { - return source.startsWith(QStringLiteral("/dev/")) + return source.startsWith(QLatin1String("/dev/")) ? source.mid(5) : source; } diff --git a/src/serialport/qserialportinfo_unix.cpp b/src/serialport/qserialportinfo_unix.cpp index 7da8f52..0add5b6 100644 --- a/src/serialport/qserialportinfo_unix.cpp +++ b/src/serialport/qserialportinfo_unix.cpp @@ -111,7 +111,7 @@ QList<QSerialPortInfo> availablePortsByFiltersOfDevices(bool &ok) static bool isSerial8250Driver(const QString &driverName) { - return (driverName == QStringLiteral("serial8250")); + return (driverName == QLatin1String("serial8250")); } static bool isValidSerial8250(const QString &systemLocation) @@ -134,7 +134,7 @@ static bool isValidSerial8250(const QString &systemLocation) static bool isRfcommDevice(const QString &portName) { - if (!portName.startsWith(QStringLiteral("rfcomm"))) + if (!portName.startsWith(QLatin1String("rfcomm"))) return false; bool ok; @@ -170,7 +170,7 @@ static QString deviceName(const QDir &targetDir) static QString deviceDriver(const QDir &targetDir) { - const QDir deviceDir(targetDir.absolutePath() + QStringLiteral("/device")); + const QDir deviceDir(targetDir.absolutePath() + QLatin1String("/device")); return ueventProperty(deviceDir, "DRIVER="); } @@ -472,14 +472,14 @@ bool QSerialPortInfo::isValid() const QString QSerialPortInfoPrivate::portNameToSystemLocation(const QString &source) { return (source.startsWith(QLatin1Char('/')) - || source.startsWith(QStringLiteral("./")) - || source.startsWith(QStringLiteral("../"))) - ? source : (QStringLiteral("/dev/") + source); + || source.startsWith(QLatin1String("./")) + || source.startsWith(QLatin1String("../"))) + ? source : (QLatin1String("/dev/") + source); } QString QSerialPortInfoPrivate::portNameFromSystemLocation(const QString &source) { - return source.startsWith(QStringLiteral("/dev/")) + return source.startsWith(QLatin1String("/dev/")) ? source.mid(5) : source; } diff --git a/src/serialport/qserialportinfo_win.cpp b/src/serialport/qserialportinfo_win.cpp index df0942f..546d5e1 100644 --- a/src/serialport/qserialportinfo_win.cpp +++ b/src/serialport/qserialportinfo_win.cpp @@ -258,13 +258,13 @@ static QString parseDeviceSerialNumber(const QString &instanceIdentifier) { int firstbound = instanceIdentifier.lastIndexOf(QLatin1Char('\\')); int lastbound = instanceIdentifier.indexOf(QLatin1Char('_'), firstbound); - if (instanceIdentifier.startsWith(QStringLiteral("USB\\"))) { + if (instanceIdentifier.startsWith(QLatin1String("USB\\"))) { if (lastbound != instanceIdentifier.size() - 3) lastbound = instanceIdentifier.size(); int ampersand = instanceIdentifier.indexOf(QLatin1Char('&'), firstbound); if (ampersand != -1 && ampersand < lastbound) return QString(); - } else if (instanceIdentifier.startsWith(QStringLiteral("FTDIBUS\\"))) { + } else if (instanceIdentifier.startsWith(QLatin1String("FTDIBUS\\"))) { firstbound = instanceIdentifier.lastIndexOf(QLatin1Char('+')); lastbound = instanceIdentifier.indexOf(QLatin1Char('\\'), firstbound); if (lastbound == -1) @@ -304,7 +304,7 @@ QList<QSerialPortInfo> QSerialPortInfo::availablePorts() DWORD index = 0; while (::SetupDiEnumDeviceInfo(deviceInfoSet, index++, &deviceInfoData)) { const QString portName = devicePortName(deviceInfoSet, &deviceInfoData); - if (portName.isEmpty() || portName.contains(QStringLiteral("LPT"))) + if (portName.isEmpty() || portName.contains(QLatin1String("LPT"))) continue; if (std::find_if(serialPortInfoList.begin(), serialPortInfoList.end(), @@ -381,14 +381,14 @@ bool QSerialPortInfo::isValid() const QString QSerialPortInfoPrivate::portNameToSystemLocation(const QString &source) { - return source.startsWith(QStringLiteral("COM")) - ? (QStringLiteral("\\\\.\\") + source) : source; + return source.startsWith(QLatin1String("COM")) + ? (QLatin1String("\\\\.\\") + source) : source; } QString QSerialPortInfoPrivate::portNameFromSystemLocation(const QString &source) { - return (source.startsWith(QStringLiteral("\\\\.\\")) - || source.startsWith(QStringLiteral("//./"))) + return (source.startsWith(QLatin1String("\\\\.\\")) + || source.startsWith(QLatin1String("//./"))) ? source.mid(4) : source; } |