package/inc/zipfileaccess.hxx | 2 +- package/source/zippackage/zipfileaccess.cxx | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-)
New commits: commit f6bf58503dda832bad97b262e4feed633fdd4853 Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Tue Sep 27 09:45:33 2022 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Tue Sep 27 13:32:26 2022 +0200 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.gran...@collabora.co.uk> 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;