From 786d0b9abf76b2f84d333e18c902a374ab3b3090 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Mon, 15 Jun 2020 09:26:24 +0200 Subject: [PATCH] small optimisations remove a couple of string copies in the XML parser, which is always a hot path Change-Id: I84460ce13fb197bc7a3d354ff4c39d6939ff1d7e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/96313 Tested-by: Jenkins Reviewed-by: Noel Grandin --- sax/source/fastparser/fastparser.cxx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/sax/source/fastparser/fastparser.cxx b/sax/source/fastparser/fastparser.cxx index 49648fe626b2..a10ccdbcae24 100644 --- a/sax/source/fastparser/fastparser.cxx +++ b/sax/source/fastparser/fastparser.cxx @@ -1227,9 +1227,12 @@ void FastSaxParserImpl::callbackStartElement(const xmlChar *localName , const xm nNamespaceToken = GetNamespaceToken( sNamespace ); aElementPrefix = OUString( XML_CAST( prefix ), strlen( XML_CAST( prefix )), RTL_TEXTENCODING_UTF8 ); } - const OUString& rElementLocalName = OUString( XML_CAST( localName ), strlen( XML_CAST( localName )), RTL_TEXTENCODING_UTF8 ); + OUString aElementLocalName( XML_CAST( localName ), strlen( XML_CAST( localName )), RTL_TEXTENCODING_UTF8 ); rEvent.msNamespace = sNamespace; - rEvent.msElementName = (aElementPrefix.isEmpty())? rElementLocalName : aElementPrefix + ":" + rElementLocalName; + if( aElementPrefix.isEmpty() ) + rEvent.msElementName = std::move(aElementLocalName); + else + rEvent.msElementName = aElementPrefix + ":" + aElementLocalName; } else // token is always preferred. rEvent.msElementName.clear(); @@ -1305,7 +1308,7 @@ void FastSaxParserImpl::sendPendingCharacters() if (rEntity.mbEnableThreads) { Event& rEvent = rEntity.getEvent( CallbackType::CHARACTERS ); - rEvent.msChars = sChars; + rEvent.msChars = std::move(sChars); produce(); } else