From 68c84e8f708334c7894ab497de403b5c009a4931 Mon Sep 17 00:00:00 2001 From: Ivailo Monev Date: Mon, 24 Feb 2020 17:14:26 +0000 Subject: [PATCH] avoid relocations in QString::arg() QChar/char overloads QString's += operator reallocates data and the temporary shared null will not be used Signed-off-by: Ivailo Monev --- src/core/tools/qstring.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/core/tools/qstring.cpp b/src/core/tools/qstring.cpp index bc02ef398..3247c918a 100644 --- a/src/core/tools/qstring.cpp +++ b/src/core/tools/qstring.cpp @@ -6256,9 +6256,7 @@ QString QString::arg(qulonglong a, int fieldWidth, int base, const QChar &fillCh */ QString QString::arg(QChar a, int fieldWidth, const QChar &fillChar) const { - QString c; - c += a; - return arg(c, fieldWidth, fillChar); + return arg(QString(a), fieldWidth, fillChar); } /*! @@ -6268,9 +6266,7 @@ QString QString::arg(QChar a, int fieldWidth, const QChar &fillChar) const */ QString QString::arg(char a, int fieldWidth, const QChar &fillChar) const { - QString c; - c += QLatin1Char(a); - return arg(c, fieldWidth, fillChar); + return arg(QString(QChar::fromLatin1(a)), fieldWidth, fillChar); } /*!