summaryrefslogtreecommitdiffstats
path: root/src/corelib/io/qurlidna.cpp
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2020-04-23 18:02:56 +0200
committerMarc Mutz <marc.mutz@kdab.com>2020-05-02 05:29:58 +0000
commit2e69375616f9a4a2ffaa470c0d9a6865685e0104 (patch)
tree629949cf0b0bd1c1d4aca5df0e68f2f787037159 /src/corelib/io/qurlidna.cpp
parentf3449b4d0a11285ec880c07284437513c701a025 (diff)
QUrlIdna: port nextDotDelimiter() to QStringView
Change-Id: I4fec88be2dacadcbb72927b973a51e1ead178c88 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/io/qurlidna.cpp')
-rw-r--r--src/corelib/io/qurlidna.cpp13
1 files changed, 6 insertions, 7 deletions
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);