summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorNoel Grandin <noelgrandin@gmail.com>2019-10-17 20:33:50 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2019-10-21 08:36:01 +0200
commit0f874472c672175135520101837ff0c9d4701d7f (patch)
treefa6a504bdfc7d5d838caed7cfb87793321797290 /tools
parent9112c18524c9f5e67d6cbb282586a439e3020cdb (diff)
size some stringbuffer to prevent re-alloc
found by the simple expidient of putting asserts in the resize routine. Where an explicit const size is used, I started with 32 and kept doubling until that site did not need resizing anymore. Change-Id: I998787edc940d0a3ba23b5ac37131ab9ecd300f4 Reviewed-on: https://gerrit.libreoffice.org/81138 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'tools')
-rw-r--r--tools/source/fsys/urlobj.cxx25
-rw-r--r--tools/source/inet/inetmime.cxx4
-rw-r--r--tools/source/misc/extendapplicationenvironment.cxx2
3 files changed, 17 insertions, 14 deletions
diff --git a/tools/source/fsys/urlobj.cxx b/tools/source/fsys/urlobj.cxx
index 91fe51a9e283..39992a1834ca 100644
--- a/tools/source/fsys/urlobj.cxx
+++ b/tools/source/fsys/urlobj.cxx
@@ -231,9 +231,12 @@ inline sal_Int32 INetURLObject::SubString::clear()
inline sal_Int32 INetURLObject::SubString::set(OUStringBuffer & rString,
OUString const & rSubString)
{
- OUString sTemp(rString.makeStringAndClear());
- sal_Int32 nDelta = set(sTemp, rSubString);
- rString.append(sTemp);
+ sal_Int32 nDelta = rSubString.getLength() - m_nLength;
+
+ rString.remove(m_nBegin, m_nLength);
+ rString.insert(m_nBegin, rSubString);
+
+ m_nLength = rSubString.getLength();
return nDelta;
}
@@ -698,7 +701,7 @@ bool INetURLObject::setAbsURIRef(OUString const & rTheAbsURIRef,
sal_uInt32 nFragmentDelimiter = '#';
- OUStringBuffer aSynAbsURIRef;
+ OUStringBuffer aSynAbsURIRef(rTheAbsURIRef.getLength()*2);
// Parse <scheme>:
sal_Unicode const * p = pPos;
@@ -949,7 +952,7 @@ bool INetURLObject::setAbsURIRef(OUString const & rTheAbsURIRef,
return false;
}
aSynAbsURIRef.append("//");
- OUStringBuffer aSynUser;
+ OUStringBuffer aSynUser(128);
bool bHasUser = false;
while (pPos < pEnd && *pPos != '@'
@@ -966,7 +969,7 @@ bool INetURLObject::setAbsURIRef(OUString const & rTheAbsURIRef,
bHasUser = *pPos == '@';
}
- OUStringBuffer aSynAuthority;
+ OUStringBuffer aSynAuthority(64);
if ( !bHasUser )
{
aSynAuthority = aSynUser;
@@ -2875,7 +2878,7 @@ bool INetURLObject::parsePath(INetProtocol eScheme,
DBG_ASSERT(pBegin, "INetURLObject::parsePath(): Null output param");
sal_Unicode const * pPos = *pBegin;
- OUStringBuffer aTheSynPath;
+ OUStringBuffer aTheSynPath(256);
switch (eScheme)
{
@@ -3267,7 +3270,7 @@ bool INetURLObject::insertName(OUString const & rTheName,
}
}
- OUStringBuffer aNewPath;
+ OUStringBuffer aNewPath(256);
aNewPath.append(pPathBegin, pPrefixEnd - pPathBegin);
aNewPath.append('/');
aNewPath.append(encodeText(rTheName, PART_PCHAR,
@@ -3392,7 +3395,7 @@ OUString INetURLObject::decode(sal_Unicode const * pBegin,
default:
break;
}
- OUStringBuffer aResult;
+ OUStringBuffer aResult(static_cast<int>(pEnd-pBegin));
while (pBegin < pEnd)
{
EscapeType eEscapeType;
@@ -3960,7 +3963,7 @@ bool INetURLObject::removeSegment(sal_Int32 nIndex, bool bIgnoreFinalSlash)
if (!aSegment.isPresent())
return false;
- OUStringBuffer aNewPath;
+ OUStringBuffer aNewPath(m_aPath.getLength());
aNewPath.append(m_aAbsURIRef.getStr() + m_aPath.getBegin(),
aSegment.getBegin() - m_aPath.getBegin());
if (bIgnoreFinalSlash && aSegment.getEnd() == m_aPath.getEnd())
@@ -4159,7 +4162,7 @@ bool INetURLObject::setExtension(OUString const & rTheExtension,
if (!pExtension)
pExtension = p;
- OUStringBuffer aNewPath;
+ OUStringBuffer aNewPath(128);
aNewPath.append(pPathBegin, pExtension - pPathBegin);
aNewPath.append('.');
aNewPath.append(encodeText(rTheExtension, PART_PCHAR,
diff --git a/tools/source/inet/inetmime.cxx b/tools/source/inet/inetmime.cxx
index f1c9080996dd..f974c911013c 100644
--- a/tools/source/inet/inetmime.cxx
+++ b/tools/source/inet/inetmime.cxx
@@ -373,7 +373,7 @@ bool parseParameters(ParameterList const & rInput,
= getCharsetEncoding(it->m_aCharset.getStr(),
it->m_aCharset.getStr()
+ it->m_aCharset.getLength());
- OUStringBuffer aValue;
+ OUStringBuffer aValue(64);
bool bBadEncoding = false;
itNext = it;
do
@@ -715,7 +715,7 @@ sal_Unicode const * scanParameters(sal_Unicode const * pBegin,
else if (p != pEnd && *p == '"')
if (pParameters)
{
- OStringBuffer aSink;
+ OStringBuffer aSink(256);
bool bInvalid = false;
for (++p;;)
{
diff --git a/tools/source/misc/extendapplicationenvironment.cxx b/tools/source/misc/extendapplicationenvironment.cxx
index 64e1d9801a79..0324a7d0d380 100644
--- a/tools/source/misc/extendapplicationenvironment.cxx
+++ b/tools/source/misc/extendapplicationenvironment.cxx
@@ -47,7 +47,7 @@ void extendApplicationEnvironment() {
#endif
// Make sure URE_BOOTSTRAP environment variable is set (failure is fatal):
- OUStringBuffer env;
+ OUStringBuffer env(512);
OUString envVar("URE_BOOTSTRAP");
OUString uri;
if (rtl::Bootstrap::get(envVar, uri))