From 0d55188fbf7b0399f01bae521f1a34d22ad8ba18 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Wed, 13 Apr 2022 16:14:26 +0200 Subject: use more string_view in xmloff Change-Id: I0d860fa6e3d3261f3393e912b27930066dd93f7c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132972 Tested-by: Jenkins Reviewed-by: Noel Grandin --- xmloff/source/draw/shapeexport.cxx | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'xmloff/source/draw') diff --git a/xmloff/source/draw/shapeexport.cxx b/xmloff/source/draw/shapeexport.cxx index bc642d344e68..55de243f07aa 100644 --- a/xmloff/source/draw/shapeexport.cxx +++ b/xmloff/source/draw/shapeexport.cxx @@ -90,6 +90,7 @@ #include #include +#include #include #include @@ -2408,22 +2409,22 @@ void XMLShapeExport::ImpExportPolygonShape( namespace { -OUString getNameFromStreamURL(OUString const & rURL) +OUString getNameFromStreamURL(std::u16string_view rURL) { - static const OUStringLiteral sPackageURL(u"vnd.sun.star.Package:"); + static constexpr std::u16string_view sPackageURL(u"vnd.sun.star.Package:"); OUString sResult; - if (rURL.match(sPackageURL)) + if (o3tl::starts_with(rURL, sPackageURL)) { - OUString sRequestedName = rURL.copy(sPackageURL.getLength()); - sal_Int32 nLastIndex = sRequestedName.lastIndexOf('/') + 1; - if ((nLastIndex > 0) && (nLastIndex < sRequestedName.getLength())) - sRequestedName = sRequestedName.copy(nLastIndex); - nLastIndex = sRequestedName.lastIndexOf('.'); - if (nLastIndex >= 0) - sRequestedName = sRequestedName.copy(0, nLastIndex); - if (!sRequestedName.isEmpty()) + std::u16string_view sRequestedName = rURL.substr(sPackageURL.size()); + size_t nLastIndex = sRequestedName.rfind('/') + 1; + if ((nLastIndex > 0) && (nLastIndex < sRequestedName.size())) + sRequestedName = sRequestedName.substr(nLastIndex); + nLastIndex = sRequestedName.rfind('.'); + if (nLastIndex != std::u16string_view::npos) + sRequestedName = sRequestedName.substr(0, nLastIndex); + if (!sRequestedName.empty()) sResult = sRequestedName; } -- cgit v1.2.3