From e276c812648bf511d6c4813d6fd82a00391cfdac Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Thu, 17 Oct 2019 20:33:50 +0200 Subject: size some stringbuffer to prevent re-alloc I started with 32 and kept doubling the size until the site did not need re-alloc, but clamped it at 512 (e.g. in emfio/). Change-Id: Ib7caf35a1b7e42b0e4ed8aa812493449e3eefc8f Reviewed-on: https://gerrit.libreoffice.org/81540 Tested-by: Jenkins Reviewed-by: Noel Grandin --- tools/source/debug/debug.cxx | 3 ++- tools/source/fsys/urlobj.cxx | 7 ++++--- 2 files changed, 6 insertions(+), 4 deletions(-) (limited to 'tools') diff --git a/tools/source/debug/debug.cxx b/tools/source/debug/debug.cxx index 4d4a817a7f40..3ab901c1aee9 100644 --- a/tools/source/debug/debug.cxx +++ b/tools/source/debug/debug.cxx @@ -406,7 +406,8 @@ OString exceptionToString(const css::uno::Any & caught) void DbgUnhandledException(const css::uno::Any & caught, const char* currentFunction, const char* fileAndLineNo, const char* area, const char* explanatory) { - OStringBuffer sMessage( "DBG_UNHANDLED_EXCEPTION in " ); + OStringBuffer sMessage( 512 ); + sMessage.append( "DBG_UNHANDLED_EXCEPTION in " ); sMessage.append(currentFunction); if (explanatory) { diff --git a/tools/source/fsys/urlobj.cxx b/tools/source/fsys/urlobj.cxx index 39992a1834ca..636bfe42ff32 100644 --- a/tools/source/fsys/urlobj.cxx +++ b/tools/source/fsys/urlobj.cxx @@ -1449,7 +1449,8 @@ bool INetURLObject::setAbsURIRef(OUString const & rTheAbsURIRef, } void INetURLObject::changeScheme(INetProtocol eTargetScheme) { - OUString aTmpStr=m_aAbsURIRef.makeStringAndClear(); + OUString aTmpStr=m_aAbsURIRef.toString(); + m_aAbsURIRef.setLength(0); int oldSchemeLen = 0; if (m_eScheme == INetProtocol::Generic) oldSchemeLen = m_aScheme.getLength(); @@ -3365,7 +3366,7 @@ OUString INetURLObject::encodeText(sal_Unicode const * pBegin, rtl_TextEncoding eCharset, bool bKeepVisibleEscapes) { - OUStringBuffer aResult; + OUStringBuffer aResult(256); while (pBegin < pEnd) { EscapeType eEscapeType; @@ -4022,7 +4023,7 @@ bool INetURLObject::setName(OUString const& rTheName, EncodeMechanism eMechanism while (p != pSegEnd && *p != ';') ++p; - OUStringBuffer aNewPath; + OUStringBuffer aNewPath(256); aNewPath.append(pPathBegin, pSegBegin - pPathBegin); aNewPath.append(encodeText(rTheName, PART_PCHAR, eMechanism, eCharset, true)); aNewPath.append(p, pPathEnd - p); -- cgit v1.2.3