DNS Lookup: Avoid unneeded allocations in parsing function
By using .compare(~~~, Qt::CaseInsensitive) instead of .toLower() Task-number: QTBUG-108873 Change-Id: I60e1fdc0a54450e7385e90f84fd509e62b82d2c9 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> Reviewed-by: Konrad Kujawa <konrad.kujawa@qt.io> Reviewed-by: Marc Mutz <marc.mutz@qt.io> (cherry picked from commit 5e16397a2cabd963c183a722c6daff6b2a32eada) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
4c470e7eef
commit
0403f09272
@ -13,25 +13,25 @@
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
static int typeFromParameter(const QString &type)
|
||||
static int typeFromParameter(QStringView type)
|
||||
{
|
||||
if (type == "a")
|
||||
if (type.compare(u"a", Qt::CaseInsensitive) == 0)
|
||||
return QDnsLookup::A;
|
||||
if (type == "aaaa")
|
||||
if (type.compare(u"aaaa", Qt::CaseInsensitive) == 0)
|
||||
return QDnsLookup::AAAA;
|
||||
if (type == "any")
|
||||
if (type.compare(u"any", Qt::CaseInsensitive) == 0)
|
||||
return QDnsLookup::ANY;
|
||||
if (type == "cname")
|
||||
if (type.compare(u"cname", Qt::CaseInsensitive) == 0)
|
||||
return QDnsLookup::CNAME;
|
||||
if (type == "mx")
|
||||
if (type.compare(u"mx", Qt::CaseInsensitive) == 0)
|
||||
return QDnsLookup::MX;
|
||||
if (type == "ns")
|
||||
if (type.compare(u"ns", Qt::CaseInsensitive) == 0)
|
||||
return QDnsLookup::NS;
|
||||
if (type == "ptr")
|
||||
if (type.compare(u"ptr", Qt::CaseInsensitive) == 0)
|
||||
return QDnsLookup::PTR;
|
||||
if (type == "srv")
|
||||
if (type.compare(u"srv", Qt::CaseInsensitive) == 0)
|
||||
return QDnsLookup::SRV;
|
||||
if (type == "txt")
|
||||
if (type.compare(u"txt", Qt::CaseInsensitive) == 0)
|
||||
return QDnsLookup::TXT;
|
||||
return -1;
|
||||
}
|
||||
@ -79,7 +79,7 @@ CommandLineParseResult parseCommandLine(QCommandLineParser &parser, DnsQuery *qu
|
||||
|
||||
if (parser.isSet(typeOption)) {
|
||||
const QString typeParameter = parser.value(typeOption);
|
||||
const int type = typeFromParameter(typeParameter.toLower());
|
||||
const int type = typeFromParameter(typeParameter);
|
||||
if (type < 0) {
|
||||
*errorMessage = "Bad record type: " + typeParameter;
|
||||
return CommandLineError;
|
||||
|
Loading…
x
Reference in New Issue
Block a user