diff options
author | Noel Grandin <noelgrandin@gmail.com> | 2019-10-17 20:33:50 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-10-21 08:36:01 +0200 |
commit | 0f874472c672175135520101837ff0c9d4701d7f (patch) | |
tree | fa6a504bdfc7d5d838caed7cfb87793321797290 /sal/rtl | |
parent | 9112c18524c9f5e67d6cbb282586a439e3020cdb (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 'sal/rtl')
-rw-r--r-- | sal/rtl/bootstrap.cxx | 6 | ||||
-rw-r--r-- | sal/rtl/uri.cxx | 4 |
2 files changed, 5 insertions, 5 deletions
diff --git a/sal/rtl/bootstrap.cxx b/sal/rtl/bootstrap.cxx index 4417246e9eea..7f5d4317636a 100644 --- a/sal/rtl/bootstrap.cxx +++ b/sal/rtl/bootstrap.cxx @@ -800,7 +800,7 @@ void SAL_CALL rtl_bootstrap_expandMacros(rtl_uString ** macro) void rtl_bootstrap_encode(rtl_uString const * value, rtl_uString ** encoded) { OSL_ASSERT(value); - OUStringBuffer b; + OUStringBuffer b(value->length+5); for (sal_Int32 i = 0; i < value->length; ++i) { sal_Unicode c = value->buffer[i]; @@ -868,7 +868,7 @@ OUString expandMacros( ExpandRequestLink const * requestStack) { SAL_INFO("sal.bootstrap", "expandMacros called with: " << text); - OUStringBuffer buf; + OUStringBuffer buf(2048); for (sal_Int32 i = 0; i < text.getLength();) { @@ -975,7 +975,7 @@ OUString expandMacros( } else { - OUStringBuffer kbuf; + OUStringBuffer kbuf(text.getLength()); for (; i < text.getLength();) { sal_Int32 j = i; diff --git a/sal/rtl/uri.cxx b/sal/rtl/uri.cxx index ae88e18b8774..592b92c88525 100644 --- a/sal/rtl/uri.cxx +++ b/sal/rtl/uri.cxx @@ -638,7 +638,7 @@ void SAL_CALL rtl_uriEncode(rtl_uString * pText, sal_Bool const * pCharClass, sal_Unicode const * p = pText->buffer; sal_Unicode const * pEnd = p + pText->length; - sal_Int32 nCapacity = pText->length; + sal_Int32 nCapacity = 256; rtl_uString_new_WithLength(pResult, nCapacity); while (p < pEnd) @@ -758,9 +758,9 @@ sal_Bool SAL_CALL rtl_uriConvertRelToAbs(rtl_uString * pBaseUriRef, { // Use the strict parser algorithm from RFC 3986, section 5.2, to turn the // relative URI into an absolute one: - OUStringBuffer aBuffer; Components aRelComponents; parseUriRef(pRelUriRef, &aRelComponents); + OUStringBuffer aBuffer(256); if (aRelComponents.aScheme.isPresent()) { |