From cad7100fda1b27ba56c4d9efc6bceba62859dfbc Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Sun, 13 May 2018 21:53:07 -0700 Subject: QByteArray: add compare() with case sensitivity options MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Need to do the same for startsWith() and endsWith(). indexOf() is a lot harder. [ChangeLog][QtCore][QByteArray] Added compare(), which takes Qt::CaseSensitivity as one of the parameters. This function is more efficient than using toLower() or toUpper() and then comparing. Change-Id: Ib48364abee9f464c96c6fffd152e69bde4194df7 Reviewed-by: MÃ¥rten Nordheim Reviewed-by: Timur Pocheptsov --- src/network/kernel/qauthenticator.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/network/kernel') diff --git a/src/network/kernel/qauthenticator.cpp b/src/network/kernel/qauthenticator.cpp index a3ccf13e82..11ea40dbce 100644 --- a/src/network/kernel/qauthenticator.cpp +++ b/src/network/kernel/qauthenticator.cpp @@ -412,7 +412,7 @@ void QAuthenticatorPrivate::parseHttpResponse(const QList ¤t = values.at(i); - if (current.first.toLower() != search) + if (current.first.compare(search, Qt::CaseInsensitive) != 0) continue; QByteArray str = current.second.toLower(); if (method < Basic && str.startsWith("basic")) { @@ -443,7 +443,7 @@ void QAuthenticatorPrivate::parseHttpResponse(const QListoptions[QLatin1String("realm")] = realm = QString::fromLatin1(options.value("realm")); - if (options.value("stale").toLower() == "true") + if (options.value("stale").compare("true", Qt::CaseInsensitive) == 0) phase = Start; if (user.isEmpty() && password.isEmpty()) phase = Done; @@ -630,7 +630,7 @@ static QByteArray digestMd5ResponseHelper( hash.addData(":", 1); hash.addData(password); QByteArray ha1 = hash.result(); - if (alg.toLower() == "md5-sess") { + if (alg.compare("md5-sess", Qt::CaseInsensitive) == 0) { hash.reset(); // RFC 2617 contains an error, it was: // hash.addData(ha1); @@ -650,7 +650,7 @@ static QByteArray digestMd5ResponseHelper( hash.addData(method); hash.addData(":", 1); hash.addData(digestUri); - if (qop.toLower() == "auth-int") { + if (qop.compare("auth-int", Qt::CaseInsensitive) == 0) { hash.addData(":", 1); hash.addData(hEntity); } -- cgit v1.2.3