include/sax/fshelper.hxx | 8 +++----- sax/source/tools/fastserializer.cxx | 2 +- sax/source/tools/fastserializer.hxx | 4 ++-- sax/source/tools/fshelper.cxx | 18 ++++-------------- sc/source/filter/excel/xecontent.cxx | 2 +- sc/source/filter/excel/xeextlst.cxx | 4 ++-- 6 files changed, 13 insertions(+), 25 deletions(-)
New commits: commit 58481b4e65c4dbf261ae9bce580ca185d9fd4c5a Author: Caolán McNamara <caolan.mcnam...@collabora.com> AuthorDate: Mon Feb 24 21:20:27 2025 +0000 Commit: Caolán McNamara <caolan.mcnam...@collabora.com> CommitDate: Wed Feb 26 09:30:01 2025 +0000 use std::string_view for TokenValue we will need the length anyway, and in the case that its constructed from OString then that strlen can be elided. (For the const char* case then std::string_view[4] will compute the len) Change-Id: Ifc06595573625cf93f07dd72ceec8a20745e12f9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/182123 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com> diff --git a/include/sax/fshelper.hxx b/include/sax/fshelper.hxx index 5006a584d352..83c3f9d3a71f 100644 --- a/include/sax/fshelper.hxx +++ b/include/sax/fshelper.hxx @@ -128,14 +128,13 @@ public: void startElement(sal_Int32 elementTokenId, const rtl::Reference<FastAttributeList>& xAttrList); - FastSerializerHelper* write(const char* value); - FastSerializerHelper* write(const OString& value); + FastSerializerHelper* write(std::string_view value); FastSerializerHelper* write(std::u16string_view value); FastSerializerHelper* write(sal_Int32 value); FastSerializerHelper* write(sal_Int64 value); FastSerializerHelper* write(double value); - FastSerializerHelper* writeEscaped(const char* value); + FastSerializerHelper* writeEscaped(std::string_view value); FastSerializerHelper* writeEscaped(std::u16string_view value); FastSerializerHelper* writeId(sal_Int32 tokenId); @@ -153,8 +152,7 @@ public: void setAllowXEscape(bool bSet); private: - void pushAttributeValue( sal_Int32 attribute, const char* value ); - void pushAttributeValue( sal_Int32 attribute, const OString& value ); + void pushAttributeValue(sal_Int32 attribute, std::string_view value); std::unique_ptr<FastSaxSerializer> mpSerializer; }; diff --git a/sax/source/tools/fastserializer.cxx b/sax/source/tools/fastserializer.cxx index 6a5ef7d48ba9..5837fa3c0d6c 100644 --- a/sax/source/tools/fastserializer.cxx +++ b/sax/source/tools/fastserializer.cxx @@ -443,7 +443,7 @@ namespace sax_fastparser { write("=\""); - write(rTokenValue.pValue, -1, true); + write(rTokenValue.pValue, true); write("\""); } diff --git a/sax/source/tools/fastserializer.hxx b/sax/source/tools/fastserializer.hxx index fc5d6c838717..55d718ba4c51 100644 --- a/sax/source/tools/fastserializer.hxx +++ b/sax/source/tools/fastserializer.hxx @@ -37,8 +37,8 @@ namespace sax_fastparser { struct TokenValue { sal_Int32 nToken; - const char *pValue; - TokenValue(sal_Int32 _nToken, const char *_pValue) : nToken(_nToken), pValue(_pValue) {} + std::string_view pValue; + TokenValue(sal_Int32 _nToken, std::string_view _pValue) : nToken(_nToken), pValue(_pValue) {} }; typedef std::vector<TokenValue> TokenValueList; diff --git a/sax/source/tools/fshelper.cxx b/sax/source/tools/fshelper.cxx index f5945d67a9c0..744fbefb78ef 100644 --- a/sax/source/tools/fshelper.cxx +++ b/sax/source/tools/fshelper.cxx @@ -57,14 +57,10 @@ void FastSerializerHelper::startElement(sal_Int32 elementTokenId) { mpSerializer->startFastElement(elementTokenId); } -void FastSerializerHelper::pushAttributeValue(sal_Int32 attribute, const char* value) +void FastSerializerHelper::pushAttributeValue(sal_Int32 attribute, std::string_view value) { mpSerializer->getTokenValueList().emplace_back(attribute, value); } -void FastSerializerHelper::pushAttributeValue(sal_Int32 attribute, const OString& value) -{ - mpSerializer->getTokenValueList().emplace_back(attribute, value.getStr()); -} void FastSerializerHelper::singleElement(sal_Int32 elementTokenId) { mpSerializer->singleFastElement(elementTokenId); @@ -87,13 +83,7 @@ void FastSerializerHelper::singleElement(sal_Int32 elementTokenId, const rtl::Re mpSerializer->singleFastElement(elementTokenId, xAttrList.get()); } -FastSerializerHelper* FastSerializerHelper::write(const char* value) -{ - mpSerializer->write(value, -1); - return this; -} - -FastSerializerHelper* FastSerializerHelper::write(const OString& value) +FastSerializerHelper* FastSerializerHelper::write(std::string_view value) { mpSerializer->write(value); return this; @@ -123,9 +113,9 @@ FastSerializerHelper* FastSerializerHelper::write(double value) return this; } -FastSerializerHelper* FastSerializerHelper::writeEscaped(const char* value) +FastSerializerHelper* FastSerializerHelper::writeEscaped(std::string_view value) { - mpSerializer->write(value, -1, true); + mpSerializer->write(value, true); return this; } diff --git a/sc/source/filter/excel/xecontent.cxx b/sc/source/filter/excel/xecontent.cxx index aad8a9cdcfde..263c55ee5f5d 100644 --- a/sc/source/filter/excel/xecontent.cxx +++ b/sc/source/filter/excel/xecontent.cxx @@ -1091,7 +1091,7 @@ void XclExpCFImpl::SaveXml( XclExpXmlStream& rStrm ) { rWorksheet->startElement(XML_formula); OString aFormula = GetFixedFormula(eOperation, maOrigin, aText); - rWorksheet->writeEscaped(aFormula.getStr()); + rWorksheet->writeEscaped(aFormula); rWorksheet->endElement( XML_formula ); } else if(RequiresFormula(eOperation)) diff --git a/sc/source/filter/excel/xeextlst.cxx b/sc/source/filter/excel/xeextlst.cxx index 8d36f639b1f3..c2b9e3469802 100644 --- a/sc/source/filter/excel/xeextlst.cxx +++ b/sc/source/filter/excel/xeextlst.cxx @@ -138,7 +138,7 @@ void XclExpExtCfvo::SaveXml( XclExpXmlStream& rStrm ) meType == COLORSCALE_VALUE) { rWorksheet->startElementNS(XML_xm, XML_f); - rWorksheet->writeEscaped(maValue.getStr()); + rWorksheet->writeEscaped(maValue); rWorksheet->endElementNS(XML_xm, XML_f); } @@ -247,7 +247,7 @@ void XclExpExtCF::SaveXml( XclExpXmlStream& rStrm ) OString aFixedFormulaText = aFormula.toUtf8(); OString aFixedFormula = GetFixedFormula(eOperation, aFixedFormulaPos, aFixedFormulaText); rWorksheet->startElementNS( XML_xm, XML_f ); - rWorksheet->writeEscaped(aFixedFormula.getStr()); + rWorksheet->writeEscaped(aFixedFormula); rWorksheet->endElementNS( XML_xm, XML_f ); rWorksheet->startElementNS( XML_xm, XML_f );