From 8f5368185661eefcd5e6e6696ac429022e0a983c Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Tue, 6 Feb 2024 12:49:27 +0200 Subject: return string_view from some XmlWalker methods elides some OString temporaries Change-Id: Ic07f18eb3c71637593e64128605c1ebfa8e68474 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163044 Tested-by: Jenkins Reviewed-by: Noel Grandin --- tools/qa/cppunit/test_xmlwalker.cxx | 6 +++--- tools/source/xml/XmlWalker.cxx | 9 ++++++--- 2 files changed, 9 insertions(+), 6 deletions(-) (limited to 'tools') diff --git a/tools/qa/cppunit/test_xmlwalker.cxx b/tools/qa/cppunit/test_xmlwalker.cxx index 6df278c21e2e..d18f3f5db487 100644 --- a/tools/qa/cppunit/test_xmlwalker.cxx +++ b/tools/qa/cppunit/test_xmlwalker.cxx @@ -41,7 +41,7 @@ void XmlWalkerTest::testReadXML() tools::XmlWalker aWalker; SvFileStream aFileStream(aXmlFilePath, StreamMode::READ); CPPUNIT_ASSERT(aWalker.open(&aFileStream)); - CPPUNIT_ASSERT_EQUAL("root"_ostr, aWalker.name()); + CPPUNIT_ASSERT_EQUAL(std::string_view("root"), aWalker.name()); CPPUNIT_ASSERT_EQUAL("Hello World"_ostr, aWalker.attribute("root-attr"_ostr)); int nNumberOfChildNodes = 0; @@ -76,8 +76,8 @@ void XmlWalkerTest::testReadXML() } else if (aWalker.name() == "with-namespace") { - CPPUNIT_ASSERT_EQUAL("adobe:ns:meta/"_ostr, aWalker.namespaceHref()); - CPPUNIT_ASSERT_EQUAL("xx"_ostr, aWalker.namespacePrefix()); + CPPUNIT_ASSERT_EQUAL(std::string_view("adobe:ns:meta/"), aWalker.namespaceHref()); + CPPUNIT_ASSERT_EQUAL(std::string_view("xx"), aWalker.namespacePrefix()); } aWalker.next(); } diff --git a/tools/source/xml/XmlWalker.cxx b/tools/source/xml/XmlWalker.cxx index c0e8a2abef48..f486cef36b34 100644 --- a/tools/source/xml/XmlWalker.cxx +++ b/tools/source/xml/XmlWalker.cxx @@ -59,14 +59,17 @@ bool XmlWalker::open(SvStream* pStream) return true; } -OString XmlWalker::name() { return reinterpret_cast(mpImpl->mpCurrent->name); } +std::string_view XmlWalker::name() +{ + return reinterpret_cast(mpImpl->mpCurrent->name); +} -OString XmlWalker::namespaceHref() +std::string_view XmlWalker::namespaceHref() { return reinterpret_cast(mpImpl->mpCurrent->ns->href); } -OString XmlWalker::namespacePrefix() +std::string_view XmlWalker::namespacePrefix() { return reinterpret_cast(mpImpl->mpCurrent->ns->prefix); } -- cgit