From 09f5bb99699e0c31dc7ba9b02a29a1d78d26323e Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Sat, 11 Feb 2023 20:37:52 -0800 Subject: QString: make insert_helper take the insertee by const-ref MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Not all callers pass a view-type object: there are several call points passing a QVarLengthArray, which means the value ended up being copied. Introduced in 67108ef8db0b134908a88e2da7a533be98f0c796. Found by Coverity scan (CID 404702). Change-Id: I9671dee8ceb64aa9b9cafffd1742f9cda2131752 Reviewed-by: Ahmad Samir Reviewed-by: MÃ¥rten Nordheim --- src/corelib/text/qstring.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/corelib/text') diff --git a/src/corelib/text/qstring.cpp b/src/corelib/text/qstring.cpp index 14cce79eed..b07e0f57fe 100644 --- a/src/corelib/text/qstring.cpp +++ b/src/corelib/text/qstring.cpp @@ -2943,7 +2943,7 @@ QString &QString::operator=(QChar ch) T is a view or a container on/of QChar, char16_t, or char */ template -static void insert_helper(QString &str, qsizetype i, T toInsert) +static void insert_helper(QString &str, qsizetype i, const T &toInsert) { auto &str_d = str.data_ptr(); qsizetype difference = 0; -- cgit v1.2.3