summaryrefslogtreecommitdiff
path: root/writerfilter/source/rtftok/rtfdocumentimpl.cxx
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-26 12:38:33 +0200
commite276c812648bf511d6c4813d6fd82a00391cfdac (patch)
treeadbf24f41bef128a081cc1cc117c8023a3eed65d /writerfilter/source/rtftok/rtfdocumentimpl.cxx
parentd04f044f05b4d13c3c6ea3f33fddd9c05a0ab3ad (diff)
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 <noel.grandin@collabora.co.uk>
Diffstat (limited to 'writerfilter/source/rtftok/rtfdocumentimpl.cxx')
-rw-r--r--writerfilter/source/rtftok/rtfdocumentimpl.cxx17
1 files changed, 10 insertions, 7 deletions
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index c396f7fb1787..f2873ecf97b8 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -1181,7 +1181,7 @@ RTFError RTFDocumentImpl::resolveChars(char ch)
return RTFError::OK;
}
- OStringBuffer aBuf;
+ OStringBuffer aBuf(512);
bool bUnicodeChecked = false;
bool bSkipped = false;
@@ -1275,8 +1275,9 @@ RTFError RTFDocumentImpl::resolveChars(char ch)
return RTFError::OK;
}
- OUString aOUStr(OStringToOUString(aStr, m_aStates.top().getCurrentEncoding()));
- SAL_INFO("writerfilter.rtf", "RTFDocumentImpl::resolveChars: collected '" << aOUStr << "'");
+ SAL_INFO("writerfilter.rtf",
+ "RTFDocumentImpl::resolveChars: collected '"
+ << OStringToOUString(aStr, m_aStates.top().getCurrentEncoding()) << "'");
if (m_aStates.top().getDestination() == Destination::COLORTABLE)
{
@@ -2323,7 +2324,7 @@ RTFError RTFDocumentImpl::popState()
{
OUString aOrig = pValue->getString();
- OUStringBuffer aBuf;
+ OUStringBuffer aBuf(aOrig.getLength() * 2);
sal_Int32 nReplaces = 1;
for (int i = 0; i < aOrig.getLength(); i++)
{
@@ -2337,7 +2338,7 @@ RTFError RTFDocumentImpl::popState()
- aState.getLevelNumbers().size()));
}
else
- aBuf.append(std::u16string_view(aOrig).substr(i, 1));
+ aBuf.append(aOrig[i]);
}
pValue->setString(aBuf.makeStringAndClear());
@@ -3566,7 +3567,8 @@ void RTFDocumentImpl::checkUnicode(bool bUnicode, bool bHex)
{
if (bUnicode && !m_aUnicodeBuffer.isEmpty())
{
- OUString aString = m_aUnicodeBuffer.makeStringAndClear();
+ OUString aString = m_aUnicodeBuffer.toString();
+ m_aUnicodeBuffer.setLength(0);
text(aString);
}
if (bHex && !m_aHexBuffer.isEmpty())
@@ -3575,7 +3577,8 @@ void RTFDocumentImpl::checkUnicode(bool bUnicode, bool bHex)
if (m_aStates.top().getDestination() == Destination::FONTENTRY
&& m_aStates.top().getCurrentEncoding() == RTL_TEXTENCODING_SYMBOL)
nEncoding = RTL_TEXTENCODING_MS_1252;
- OUString aString = OStringToOUString(m_aHexBuffer.makeStringAndClear(), nEncoding);
+ OUString aString = OStringToOUString(m_aHexBuffer.toString(), nEncoding);
+ m_aHexBuffer.setLength(0);
text(aString);
}
}