summaryrefslogtreecommitdiff
path: root/oox
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2023-04-07 10:02:18 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2023-04-09 20:51:44 +0200
commiteaf071397a1ff30536616f2ed76051f77fd38ed6 (patch)
treece55cdc75a0826c54b6b60458a028251f11fcb78 /oox
parent1e79befa61a08de7a1ddaccb6c435dbb8015c063 (diff)
new loplugin:unnecessarygetstr
which prevents constructing unnecessary temporaries via getStr() Change-Id: I9ca70893a10e954b5ee0e6ad6098660ee24c2bef Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150170 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'oox')
-rw-r--r--oox/source/core/relationshandler.cxx12
1 files changed, 8 insertions, 4 deletions
diff --git a/oox/source/core/relationshandler.cxx b/oox/source/core/relationshandler.cxx
index 07586cce0db7..5fb39fd4e140 100644
--- a/oox/source/core/relationshandler.cxx
+++ b/oox/source/core/relationshandler.cxx
@@ -40,12 +40,16 @@ namespace {
'file.xml' -> '_rels/file.xml.rels'
'' -> '_rels/.rels'
*/
-OUString lclGetRelationsPath( const OUString& rFragmentPath )
+OUString lclGetRelationsPath( std::u16string_view rFragmentPath )
{
- sal_Int32 nPathLen = ::std::max< sal_Int32 >( rFragmentPath.lastIndexOf( '/' ) + 1, 0 );
- return OUString::Concat(std::u16string_view(rFragmentPath.getStr(), nPathLen )) + // file path including slash
+ size_t nPathLen = rFragmentPath.rfind( '/' );
+ if (nPathLen == std::u16string_view::npos)
+ nPathLen = 0;
+ else
+ ++nPathLen;
+ return OUString::Concat(rFragmentPath.substr(0, nPathLen)) + // file path including slash
"_rels/" + // additional '_rels/' path
- std::u16string_view(rFragmentPath.getStr() + nPathLen) + // file name after path
+ rFragmentPath.substr(nPathLen) + // file name after path
".rels"; // '.rels' suffix
}