summaryrefslogtreecommitdiff
path: root/package
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2022-09-27 09:45:33 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2022-09-27 13:32:26 +0200
commitf6bf58503dda832bad97b262e4feed633fdd4853 (patch)
tree7a75bae65f12a93007d6611e1114bf0b85cf22f0 /package
parent0a7eac8576f313dcaf27ee45326d71fd6b5aea1e (diff)
use more string_view in package
Change-Id: Ia38b2784222701d669f244523ce9a27c4068c5ab Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140639 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'package')
-rw-r--r--package/inc/zipfileaccess.hxx2
-rw-r--r--package/source/zippackage/zipfileaccess.cxx14
2 files changed, 8 insertions, 8 deletions
diff --git a/package/inc/zipfileaccess.hxx b/package/inc/zipfileaccess.hxx
index 5d85a846cfcd..b67a44b5c1a2 100644
--- a/package/inc/zipfileaccess.hxx
+++ b/package/inc/zipfileaccess.hxx
@@ -55,7 +55,7 @@ public:
static css::uno::Sequence< OUString > GetPatternsFromString_Impl( const OUString& aString );
- static bool StringGoodForPattern_Impl( const OUString& aString,
+ static bool StringGoodForPattern_Impl( std::u16string_view,
const css::uno::Sequence< OUString >& aPattern );
// XInitialization
diff --git a/package/source/zippackage/zipfileaccess.cxx b/package/source/zippackage/zipfileaccess.cxx
index d9b17fd80b49..2921ec947209 100644
--- a/package/source/zippackage/zipfileaccess.cxx
+++ b/package/source/zippackage/zipfileaccess.cxx
@@ -117,7 +117,7 @@ uno::Sequence< OUString > OZipFileAccess::GetPatternsFromString_Impl( const OUSt
return aPattern;
}
-bool OZipFileAccess::StringGoodForPattern_Impl( const OUString& aString,
+bool OZipFileAccess::StringGoodForPattern_Impl( std::u16string_view aString,
const uno::Sequence< OUString >& aPattern )
{
sal_Int32 nInd = aPattern.getLength() - 1;
@@ -133,10 +133,10 @@ bool OZipFileAccess::StringGoodForPattern_Impl( const OUString& aString,
}
sal_Int32 nBeginInd = aPattern[0].getLength();
- sal_Int32 nEndInd = aString.getLength() - aPattern[nInd].getLength();
+ sal_Int32 nEndInd = aString.size() - aPattern[nInd].getLength();
if ( nEndInd < nBeginInd
- || ( nEndInd != aString.getLength() && aString.subView( nEndInd ) != aPattern[nInd] )
- || ( nBeginInd != 0 && aString.subView( 0, nBeginInd ) != aPattern[0] ) )
+ || ( nEndInd != sal_Int32(aString.size()) && aString.substr( nEndInd ) != aPattern[nInd] )
+ || ( nBeginInd != 0 && aString.substr( 0, nBeginInd ) != aPattern[0] ) )
return false;
for ( sal_Int32 nCurInd = aPattern.getLength() - 2; nCurInd > 0; nCurInd-- )
@@ -148,12 +148,12 @@ bool OZipFileAccess::StringGoodForPattern_Impl( const OUString& aString,
return false;
// check that search does not use nEndInd position
- sal_Int32 nLastInd = aString.lastIndexOf( aPattern[nCurInd], nEndInd - 1 );
+ size_t nLastInd = aString.substr(0, nEndInd - 1).rfind( aPattern[nCurInd] );
- if ( nLastInd == -1 )
+ if ( nLastInd == std::u16string_view::npos )
return false;
- if ( nLastInd < nBeginInd )
+ if ( sal_Int32(nLastInd) < nBeginInd )
return false;
nEndInd = nLastInd;