summaryrefslogtreecommitdiff
path: root/writerfilter
diff options
context:
space:
mode:
authorNoel Grandin <noelgrandin@gmail.com>2022-07-21 18:51:02 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2022-07-22 11:13:45 +0200
commit42572c6d0d1f1c84b3774f6c790e28e8abc7b45a (patch)
tree1a831ccd9363c89292f96dc7554a0cfa5ca7141c /writerfilter
parentaa2067dda63852b0eb84d5c32497f5a28177bb1c (diff)
elide some makeStringAndClear() calls
Change-Id: I3b7ae370b41638c0a67374d5132b7bdf56e7c672 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137311 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'writerfilter')
-rw-r--r--writerfilter/source/rtftok/rtfdocumentimpl.cxx42
-rw-r--r--writerfilter/source/rtftok/rtftokenizer.cxx3
2 files changed, 26 insertions, 19 deletions
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index e8db8d68f12e..71e25f4571f8 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -855,8 +855,9 @@ void RTFDocumentImpl::resolvePict(bool const bInline, uno::Reference<drawing::XS
int count = 2;
// Feed the destination text to a stream.
- OString aStr = OUStringToOString(m_aStates.top().getDestinationText().makeStringAndClear(),
- RTL_TEXTENCODING_ASCII_US);
+ auto& rDestinationTextBuffer = m_aStates.top().getDestinationText();
+ OString aStr = OUStringToOString(rDestinationTextBuffer, RTL_TEXTENCODING_ASCII_US);
+ rDestinationTextBuffer.setLength(0);
for (int i = 0; i < aStr.getLength(); ++i)
{
char ch = aStr[i];
@@ -2551,12 +2552,13 @@ RTFError RTFDocumentImpl::beforePopState(RTFParserState& rState)
{
if (m_bFormField)
{
- if (&m_aStates.top().getDestinationText()
- != m_aStates.top().getCurrentDestinationText())
+ OUStringBuffer* pCurrentDestinationText
+ = m_aStates.top().getCurrentDestinationText();
+ if (&m_aStates.top().getDestinationText() != pCurrentDestinationText)
break; // not for nested group
- OString aStr = OUStringToOString(
- m_aStates.top().getCurrentDestinationText()->makeStringAndClear(),
- rState.getCurrentEncoding());
+ OString aStr
+ = OUStringToOString(*pCurrentDestinationText, rState.getCurrentEncoding());
+ pCurrentDestinationText->setLength(0);
// decode hex dump
OStringBuffer aBuf;
int b = 0;
@@ -2638,8 +2640,13 @@ RTFError RTFDocumentImpl::beforePopState(RTFParserState& rState)
!= m_aStates.top().getCurrentDestinationText())
break; // not for nested group
if (m_xDocumentProperties.is())
- m_xDocumentProperties->setKeywords(comphelper::string::convertCommaSeparated(
- m_aStates.top().getCurrentDestinationText()->makeStringAndClear()));
+ {
+ OUStringBuffer* pCurrentDestinationText
+ = m_aStates.top().getCurrentDestinationText();
+ m_xDocumentProperties->setKeywords(
+ comphelper::string::convertCommaSeparated(*pCurrentDestinationText));
+ pCurrentDestinationText->setLength(0);
+ }
break;
case Destination::COMMENT:
if (&m_aStates.top().getDestinationText()
@@ -2757,13 +2764,12 @@ RTFError RTFDocumentImpl::beforePopState(RTFParserState& rState)
break;
case Destination::ANNOTATIONDATE:
{
- if (&m_aStates.top().getDestinationText()
- != m_aStates.top().getCurrentDestinationText())
+ OUStringBuffer* pCurrentDestinationText = m_aStates.top().getCurrentDestinationText();
+ if (&m_aStates.top().getDestinationText() != pCurrentDestinationText)
break; // not for nested group
- OUString aStr(OStringToOUString(
- DTTM22OString(
- m_aStates.top().getCurrentDestinationText()->makeStringAndClear().toInt32()),
- rState.getCurrentEncoding()));
+ OUString aStr(OStringToOUString(DTTM22OString(o3tl::toInt32(*pCurrentDestinationText)),
+ rState.getCurrentEncoding()));
+ pCurrentDestinationText->setLength(0);
auto pValue = new RTFValue(aStr);
RTFSprms aAnnAttributes;
aAnnAttributes.set(NS_ooxml::LN_CT_TrackChange_date, pValue);
@@ -3620,9 +3626,9 @@ RTFError RTFDocumentImpl::popState()
RTFError RTFDocumentImpl::handleEmbeddedObject()
{
- OString aStr
- = OUStringToOString(m_aStates.top().getCurrentDestinationText()->makeStringAndClear(),
- RTL_TEXTENCODING_ASCII_US);
+ OUStringBuffer* pCurrentDestinationText = m_aStates.top().getCurrentDestinationText();
+ OString aStr = OUStringToOString(*pCurrentDestinationText, RTL_TEXTENCODING_ASCII_US);
+ pCurrentDestinationText->setLength(0);
std::unique_ptr<SvStream> pStream(new SvMemoryStream());
if (!msfilter::rtfutil::ExtractOLE2FromObjdata(aStr, *pStream))
return RTFError::HEX_INVALID;
diff --git a/writerfilter/source/rtftok/rtftokenizer.cxx b/writerfilter/source/rtftok/rtftokenizer.cxx
index 4dc80416c64f..420c6d36f0c3 100644
--- a/writerfilter/source/rtftok/rtftokenizer.cxx
+++ b/writerfilter/source/rtftok/rtftokenizer.cxx
@@ -8,6 +8,7 @@
*/
#include "rtftokenizer.hxx"
+#include <o3tl/string_view.hxx>
#include <tools/stream.hxx>
#include <svx/dialmgr.hxx>
#include <svx/strings.hrc>
@@ -237,7 +238,7 @@ RTFError RTFTokenizer::resolveKeyword()
break;
}
}
- nParam = aParameter.makeStringAndClear().toInt32();
+ nParam = o3tl::toInt32(aParameter);
if (bNeg)
nParam = -nParam;
}