summaryrefslogtreecommitdiff
path: root/svl
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 /svl
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 'svl')
-rw-r--r--svl/source/numbers/zforlist.cxx29
-rw-r--r--svl/source/numbers/zformat.cxx4
2 files changed, 16 insertions, 17 deletions
diff --git a/svl/source/numbers/zforlist.cxx b/svl/source/numbers/zforlist.cxx
index 9a0660f74e24..04e32464d8b2 100644
--- a/svl/source/numbers/zforlist.cxx
+++ b/svl/source/numbers/zforlist.cxx
@@ -2719,28 +2719,27 @@ void SvNumberFormatter::ImpGenerateFormats( sal_uInt32 CLOffset, bool bNoAdditio
const NfKeywordTable & rKeyword = pFormatScanner->GetKeywords();
i18n::NumberFormatCode aSingleFormatCode;
- OUStringBuffer aBuf;
aSingleFormatCode.Usage = i18n::KNumberFormatUsage::DATE_TIME;
// YYYY-MM-DD HH:MM:SS ISO (with blank instead of 'T')
- aBuf.append( rKeyword[NF_KEY_YYYY]).append('-').
- append( rKeyword[NF_KEY_MM]).append('-').
- append( rKeyword[NF_KEY_DD]).append(' ').
- append( rKeyword[NF_KEY_HH]).append(':').
- append( rKeyword[NF_KEY_MMI]).append(':').
- append( rKeyword[NF_KEY_SS]);
- aSingleFormatCode.Code = aBuf.makeStringAndClear();
+ aSingleFormatCode.Code =
+ rKeyword[NF_KEY_YYYY] + "-" +
+ rKeyword[NF_KEY_MM] + "-" +
+ rKeyword[NF_KEY_DD] + " " +
+ rKeyword[NF_KEY_HH] + ":" +
+ rKeyword[NF_KEY_MMI] + ":" +
+ rKeyword[NF_KEY_SS];
ImpInsertFormat( aSingleFormatCode,
CLOffset + ZF_STANDARD_DATETIME+2 /* NF_DATETIME_ISO_YYYYMMDD_HHMMSS */ );
// YYYY-MM-DD"T"HH:MM:SS ISO
- aBuf.append( rKeyword[NF_KEY_YYYY]).append('-').
- append( rKeyword[NF_KEY_MM]).append('-').
- append( rKeyword[NF_KEY_DD]).append("\"T\"").
- append( rKeyword[NF_KEY_HH]).append(':').
- append( rKeyword[NF_KEY_MMI]).append(':').
- append( rKeyword[NF_KEY_SS]);
- aSingleFormatCode.Code = aBuf.makeStringAndClear();
+ aSingleFormatCode.Code =
+ rKeyword[NF_KEY_YYYY] + "-" +
+ rKeyword[NF_KEY_MM] + "-" +
+ rKeyword[NF_KEY_DD] + "\"T\"" +
+ rKeyword[NF_KEY_HH] + ":" +
+ rKeyword[NF_KEY_MMI] + ":" +
+ rKeyword[NF_KEY_SS];
SvNumberformat* pFormat = ImpInsertFormat( aSingleFormatCode,
CLOffset + ZF_STANDARD_DATETIME+3 /* NF_DATETIME_ISO_YYYYMMDDTHHMMSS */ );
assert(pFormat);
diff --git a/svl/source/numbers/zformat.cxx b/svl/source/numbers/zformat.cxx
index 63a8b5d9e3ab..41db17082089 100644
--- a/svl/source/numbers/zformat.cxx
+++ b/svl/source/numbers/zformat.cxx
@@ -1647,7 +1647,7 @@ short SvNumberformat::ImpNextSymbol(OUStringBuffer& rString,
sal_Unicode cLetter = ' '; // Preliminary result
sal_Int32 nLen = rString.getLength();
ScanState eState = SsStart;
- OUStringBuffer sBuffSymbol;
+ OUStringBuffer sBuffSymbol(32);
const NfKeywordTable & rKeywords = rScan.GetKeywords();
while (nPos < nLen && eState != SsStop)
@@ -1975,7 +1975,7 @@ bool SvNumberformat::GetNewCurrencySymbol( OUString& rSymbol,
// static
OUString SvNumberformat::StripNewCurrencyDelimiters( const OUString& rStr )
{
- OUStringBuffer aTmp;
+ OUStringBuffer aTmp(rStr.getLength());
sal_Int32 nStartPos, nPos, nLen;
nLen = rStr.getLength();
nStartPos = 0;