From 3f054d9220aee275e8a28f0e706f622f8cba923b Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 7 Apr 2025 08:27:11 -0700 Subject: [PATCH] QUrl: move intro string passed by value Amends commit 31207b539a19182b48c4b3b8413190d505633eea. Unlike the other setXxx() functions, setUserInfo() has a trimmed() call, which was retained from Qt 4's QUrl. This is probably wrong, but no one has complained in the 17 years of public Git history. As a result, the template function QUrlPrivate::setUserInfo() was getting a copy of the string, which is inefficient. We can fix that by simply moving the string and matching a move inside that function too. Coverity-Id: 480249 Coverity-Id: 480253 Change-Id: I5d9edea3174080822e82fffdd5f1548e8715e510 Reviewed-by: David Faure --- src/corelib/io/qurl.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp index 8c6fcfd09b6..7edbd7a8d79 100644 --- a/src/corelib/io/qurl.cpp +++ b/src/corelib/io/qurl.cpp @@ -1105,7 +1105,7 @@ template void QUrlPrivate::setUserInfo(String value, QUrl::Par qsizetype delimIndex = value.indexOf(u':'); if (delimIndex < 0) { // no password - setUserName(value, mode); + setUserName(std::move(value), mode); password.clear(); sectionIsPresent &= ~Password; } else { @@ -2060,7 +2060,7 @@ void QUrl::setUserInfo(const QString &userInfo, ParsingMode mode) return; } - d->setUserInfo(trimmed, mode); + d->setUserInfo(std::move(trimmed), mode); if (userInfo.isNull()) { // QUrlPrivate::setUserInfo cleared almost everything // but it leaves the UserName bit set