diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2023-05-09 11:07:18 -0700 |
---|---|---|
committer | Thiago Macieira <thiago.macieira@intel.com> | 2023-06-03 19:28:11 -0700 |
commit | 01dfcfcecf454a7bdc92980403796f1d3a49d8a4 (patch) | |
tree | fc4cdc47e9393023880dc9c36017cf5536275aa2 /src/network/kernel/qdnslookup_p.h | |
parent | eda71105ff9a516059c6dd6643ff446a82edac81 (diff) |
QDnsLookup: merge some of the domain label expansion code
Use qt_ACE_do directly from QtCore, to avoid going through Latin1
(US-ASCII) multiple times.
Drive-by reduce the size of the buffers from PACKETSZ (512) to the
maximum name a label can be (255 plus 1 for the null, just in case).
Drive-by replace the last QString::fromWCharArray with QStringView,
saving an unnecessary memory allocation before calling
QtPrivate::convertToLatin1().
Change-Id: I3e3bfef633af4130a03afffd175d8be1feb5d74b
Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
Diffstat (limited to 'src/network/kernel/qdnslookup_p.h')
-rw-r--r-- | src/network/kernel/qdnslookup_p.h | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/network/kernel/qdnslookup_p.h b/src/network/kernel/qdnslookup_p.h index 03767fd831..da4721411b 100644 --- a/src/network/kernel/qdnslookup_p.h +++ b/src/network/kernel/qdnslookup_p.h @@ -25,6 +25,7 @@ #include "QtNetwork/qdnslookup.h" #include "QtNetwork/qhostaddress.h" #include "private/qobject_p.h" +#include "private/qurl_p.h" QT_REQUIRE_CONFIG(dnslookup); @@ -174,6 +175,12 @@ class QDnsLookupRunnable : public QObject, public QRunnable Q_OBJECT public: +#ifdef Q_OS_WIN + using EncodedLabel = QString; +#else + using EncodedLabel = QByteArray; +#endif + QDnsLookupRunnable(const QDnsLookupPrivate *d); void run() override; @@ -181,8 +188,13 @@ signals: void finished(const QDnsLookupReply &reply); private: + template <typename T> static QString decodeLabel(T encodedLabel) + { + return qt_ACE_do(encodedLabel.toString(), NormalizeAce, ForbidLeadingDot); + } void query(QDnsLookupReply *reply); - QByteArray requestName; + + EncodedLabel requestName; QHostAddress nameserver; QDnsLookup::Type requestType; quint16 port; |