diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2024-02-06 12:49:27 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2024-02-06 17:08:27 +0100 |
commit | 8f5368185661eefcd5e6e6696ac429022e0a983c (patch) | |
tree | ab85b7c7abcf132361612541fb81b8bfd739832e /tools | |
parent | 0a5d4dc25c5521de221f63dbc47c6ba79a51f8fb (diff) |
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 <noel.grandin@collabora.co.uk>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/qa/cppunit/test_xmlwalker.cxx | 6 | ||||
-rw-r--r-- | tools/source/xml/XmlWalker.cxx | 9 |
2 files changed, 9 insertions, 6 deletions
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<const char*>(mpImpl->mpCurrent->name); } +std::string_view XmlWalker::name() +{ + return reinterpret_cast<const char*>(mpImpl->mpCurrent->name); +} -OString XmlWalker::namespaceHref() +std::string_view XmlWalker::namespaceHref() { return reinterpret_cast<const char*>(mpImpl->mpCurrent->ns->href); } -OString XmlWalker::namespacePrefix() +std::string_view XmlWalker::namespacePrefix() { return reinterpret_cast<const char*>(mpImpl->mpCurrent->ns->prefix); } |