cui/source/dialogs/QrCodeGenDialog.cxx | 2 +- sax/qa/cppunit/xmlimport.cxx | 24 ++++++++++++------------ svx/source/svdraw/svdpdf.cxx | 2 +- sw/qa/core/uwriter.cxx | 4 ++-- vcl/source/filter/ipdf/pdfdocument.cxx | 4 ++-- vcl/source/pdf/PDFiumLibrary.cxx | 2 +- vcl/unx/gtk3/gtkinst.cxx | 2 +- 7 files changed, 20 insertions(+), 20 deletions(-)
New commits: commit 8e86827c0f8ba82666d550e65120981bac295038 Author: Noel Grandin <[email protected]> AuthorDate: Thu Nov 20 10:38:52 2025 +0200 Commit: Noel Grandin <[email protected]> CommitDate: Fri Nov 21 07:27:18 2025 +0100 more efficient to use makeStringAndClear here to avoid a copy Change-Id: Ic1d7370d3a0bb72b34b2b92604eb02fa34ac18c4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/194242 Tested-by: Jenkins Reviewed-by: Noel Grandin <[email protected]> diff --git a/cui/source/dialogs/QrCodeGenDialog.cxx b/cui/source/dialogs/QrCodeGenDialog.cxx index fec9d7b47adb..6454e407bbf5 100644 --- a/cui/source/dialogs/QrCodeGenDialog.cxx +++ b/cui/source/dialogs/QrCodeGenDialog.cxx @@ -106,7 +106,7 @@ OString ConvertToSVGFormat(const ZXing::BitMatrix& bitmatrix) } } sb.append("\"/> </svg>"); - return sb.toString(); + return sb.makeStringAndClear(); } #endif diff --git a/svx/source/svdraw/svdpdf.cxx b/svx/source/svdraw/svdpdf.cxx index 8941a9ca648e..e492822d6cf7 100644 --- a/svx/source/svdraw/svdpdf.cxx +++ b/svx/source/svdraw/svdpdf.cxx @@ -1166,7 +1166,7 @@ static OString decomposeLegacyUnicodeLigature(UChar32 cUnicode) OStringBuffer aBuffer; for (int32_t i = 0, nLen = sDecomposed.length(); i < nLen; ++i) appendFourByteHex(aBuffer, sDecomposed[i]); - return aBuffer.toString(); + return aBuffer.makeStringAndClear(); } } } diff --git a/sw/qa/core/uwriter.cxx b/sw/qa/core/uwriter.cxx index fab8befe39b8..9a2d06845394 100644 --- a/sw/qa/core/uwriter.cxx +++ b/sw/qa/core/uwriter.cxx @@ -2021,7 +2021,7 @@ void SwDocTest::testFillRubyList() aTemp.append(rRuby->GetText() + u"["_ustr + rRuby->GetRubyAttr().GetText() + u"]"_ustr); } - return aTemp.toString(); + return aTemp.makeStringAndClear(); }; // Single word without existing rubies @@ -2226,7 +2226,7 @@ void SwDocTest::testSetRubyList() } } - return aTemp.toString(); + return aTemp.makeStringAndClear(); }; // Trivial characteristic test diff --git a/vcl/source/filter/ipdf/pdfdocument.cxx b/vcl/source/filter/ipdf/pdfdocument.cxx index 8a344e3dcf5d..bce5265de69e 100644 --- a/vcl/source/filter/ipdf/pdfdocument.cxx +++ b/vcl/source/filter/ipdf/pdfdocument.cxx @@ -1483,10 +1483,10 @@ OString PDFDocument::ReadKeyword(SvStream& rStream) aBuf.append(ch); rStream.ReadChar(ch); if (rStream.eof()) - return aBuf.toString(); + return aBuf.makeStringAndClear(); } rStream.SeekRel(-1); - return aBuf.toString(); + return aBuf.makeStringAndClear(); } size_t PDFDocument::FindStartXRef(SvStream& rStream) diff --git a/vcl/source/pdf/PDFiumLibrary.cxx b/vcl/source/pdf/PDFiumLibrary.cxx index 35d5de43c4ae..b593c5cb35dd 100644 --- a/vcl/source/pdf/PDFiumLibrary.cxx +++ b/vcl/source/pdf/PDFiumLibrary.cxx @@ -578,7 +578,7 @@ public: addLineFeed = true; } } - return aResult.toString(); + return aResult.makeStringAndClear(); } }; diff --git a/vcl/unx/gtk3/gtkinst.cxx b/vcl/unx/gtk3/gtkinst.cxx index 532aaac5c91c..2430b98b155b 100644 --- a/vcl/unx/gtk3/gtkinst.cxx +++ b/vcl/unx/gtk3/gtkinst.cxx @@ -9786,7 +9786,7 @@ OUString vcl_font_to_css(const vcl::Font& rFont) default: break; } - return sCSS.toString(); + return sCSS.makeStringAndClear(); } void update_attr_list(PangoAttrList* pAttrList, const vcl::Font& rFont) commit 59ad655a0f3673bcfad1d10e922685f1914abf43 Author: Noel Grandin <[email protected]> AuthorDate: Thu Nov 20 10:12:15 2025 +0200 Commit: Noel Grandin <[email protected]> CommitDate: Fri Nov 21 07:27:07 2025 +0100 use OUStringBuffer in TestDocumentHandler more efficient when repeatedly appending Change-Id: Ib0139637353c4c9948a048e27aaf4e66d9af6edd Reviewed-on: https://gerrit.libreoffice.org/c/core/+/194240 Reviewed-by: Noel Grandin <[email protected]> Tested-by: Jenkins diff --git a/sax/qa/cppunit/xmlimport.cxx b/sax/qa/cppunit/xmlimport.cxx index 18f8c9a21112..08014b6c8eb1 100644 --- a/sax/qa/cppunit/xmlimport.cxx +++ b/sax/qa/cppunit/xmlimport.cxx @@ -69,7 +69,7 @@ Reference< XInputStream > createStreamFromFile ( class TestDocumentHandler : public cppu::WeakImplHelper< XDocumentHandler > { private: - OUString m_aStr; + OUStringBuffer m_aStr; std::deque< std::pair<OUString,OUString> > m_aNamespaceStack; std::stack<sal_uInt16> m_aCountStack; @@ -78,7 +78,7 @@ private: public: TestDocumentHandler() {} - const OUString & getString() const { return m_aStr; } + const OUStringBuffer & getString() const { return m_aStr; } // XDocumentHandler virtual void SAL_CALL startDocument() override; @@ -134,7 +134,7 @@ OUString TestDocumentHandler::getNamespace(std::u16string_view sName) void SAL_CALL TestDocumentHandler::startDocument() { - m_aStr.clear(); + m_aStr.setLength(0); m_aNamespaceStack.clear(); m_aNamespaceStack.emplace_back( std::make_pair( u"default"_ustr, OUString() ) ); m_aCountStack = std::stack<sal_uInt16>(); @@ -158,13 +158,13 @@ void SAL_CALL TestDocumentHandler::startElement( const OUString& aName, const Re if (!sAttrName.isEmpty()) sAttributes += sAttrName + sAttrValue; } - m_aStr += canonicalform(aName, u""_ustr, true) + sAttributes; + m_aStr.append(canonicalform(aName, u""_ustr, true) + sAttributes); } void SAL_CALL TestDocumentHandler::endElement( const OUString& aName ) { - m_aStr += canonicalform(aName, u""_ustr, true); + m_aStr.append(canonicalform(aName, u""_ustr, true)); sal_uInt16 nPopQty = m_aCountStack.top(); for (sal_uInt16 i=0; i<nPopQty; i++) m_aNamespaceStack.pop_back(); @@ -174,19 +174,19 @@ void SAL_CALL TestDocumentHandler::endElement( const OUString& aName ) void SAL_CALL TestDocumentHandler::characters( const OUString& aChars ) { - m_aStr += aChars; + m_aStr.append(aChars); } void SAL_CALL TestDocumentHandler::ignorableWhitespace( const OUString& aWhitespaces ) { - m_aStr += aWhitespaces; + m_aStr.append(aWhitespaces); } void SAL_CALL TestDocumentHandler::processingInstruction( const OUString& aTarget, const OUString& aData ) { - m_aStr += aTarget + aData; + m_aStr.append(aTarget + aData); } @@ -386,11 +386,11 @@ void XMLImportTest::parse() source.aInputStream = createStreamFromFile( m_sDirPath + fileNames[i] ); m_xParser->parseStream(source); - const OUString rParserStr = m_xDocumentHandler->getString(); + const OUString rParserStr = m_xDocumentHandler->getString().toString(); source.aInputStream = createStreamFromFile( m_sDirPath + fileNames[i] ); m_xLegacyFastParser->parseStream(source); - const OUString rLegacyFastParserStr = m_xDocumentHandler->getString(); + const OUString rLegacyFastParserStr = m_xDocumentHandler->getString().toString(); CPPUNIT_ASSERT_EQUAL( rParserStr, rLegacyFastParserStr ); // OString o = OUStringToOString( Str, RTL_TEXTENCODING_ASCII_US ); @@ -415,11 +415,11 @@ void XMLImportTest::testMissingNamespaceDeclaration() source.aInputStream = createStreamFromFile( m_sDirPath + fileNames[i] ); m_xParser->parseStream(source); - const OUString rParserStr = m_xDocumentHandler->getString(); + const OUString rParserStr = m_xDocumentHandler->getString().toString(); source.aInputStream = createStreamFromFile( m_sDirPath + fileNames[i] ); m_xLegacyFastParser->parseStream(source); - const OUString rLegacyFastParserStr = m_xDocumentHandler->getString(); + const OUString rLegacyFastParserStr = m_xDocumentHandler->getString().toString(); CPPUNIT_ASSERT_EQUAL( rParserStr, rLegacyFastParserStr ); }
