From 2e69375616f9a4a2ffaa470c0d9a6865685e0104 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 23 Apr 2020 18:02:56 +0200 Subject: QUrlIdna: port nextDotDelimiter() to QStringView Change-Id: I4fec88be2dacadcbb72927b973a51e1ead178c88 Reviewed-by: Thiago Macieira --- src/corelib/io/qurlidna.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'src/corelib/io/qurlidna.cpp') diff --git a/src/corelib/io/qurlidna.cpp b/src/corelib/io/qurlidna.cpp index 2951710903..c5b205557f 100644 --- a/src/corelib/io/qurlidna.cpp +++ b/src/corelib/io/qurlidna.cpp @@ -2471,9 +2471,9 @@ static inline bool isDotDelimiter(ushort uc) return uc == 0x2e || uc == 0x3002 || uc == 0xff0e || uc == 0xff61; } -static int nextDotDelimiter(const QString &domain, int from = 0) +static qsizetype nextDotDelimiter(QStringView domain, qsizetype from = 0) { - const QChar *b = domain.unicode(); + const QChar *b = domain.data(); const QChar *ch = b + from; const QChar *e = b + domain.length(); while (ch < e) { @@ -2494,12 +2494,12 @@ QString qt_ACE_do(const QString &domain, AceOperation op, AceLeadingDot dot) result.reserve(domain.length()); const bool isIdnEnabled = op == NormalizeAce ? qt_is_idn_enabled(domain) : false; - int lastIdx = 0; + qsizetype lastIdx = 0; QString aceForm; // this variable is here for caching while (1) { - int idx = nextDotDelimiter(domain, lastIdx); - int labelLength = idx - lastIdx; + const auto idx = nextDotDelimiter(domain, lastIdx); + const auto labelLength = idx - lastIdx; if (labelLength == 0) { if (idx == domain.length()) break; @@ -2558,8 +2558,7 @@ QString qt_ACE_do(const QString &domain, AceOperation op, AceLeadingDot dot) // That means we need one or two temporaries if (!qt_nameprep(&result, prevLen)) return QString(); // failed - labelLength = result.length() - prevLen; - int toReserve = labelLength + 4 + 6; // "xn--" plus some extra bytes + const auto toReserve = result.length() - prevLen + 4 + 6; // "xn--" plus some extra bytes aceForm.resize(0); if (toReserve > aceForm.capacity()) aceForm.reserve(toReserve); -- cgit v1.2.3