From 8e77be57024fa9422db2dddce7c0c7ef4302a3c2 Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Mon, 25 Apr 2022 17:02:42 +0200 Subject: loplugin:stringviewparam ...and loplugin:stringview(param) follow-ups Change-Id: I5ccb5c7b246a35aefb43c8f608d781b753f9830c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133392 Tested-by: Jenkins Reviewed-by: Stephan Bergmann --- fpicker/source/aqua/FilterHelper.hxx | 3 ++- fpicker/source/aqua/FilterHelper.mm | 33 +++++++++++++++++---------------- 2 files changed, 19 insertions(+), 17 deletions(-) (limited to 'fpicker') diff --git a/fpicker/source/aqua/FilterHelper.hxx b/fpicker/source/aqua/FilterHelper.hxx index 6cf4aec5996e..21cb9c4b4464 100644 --- a/fpicker/source/aqua/FilterHelper.hxx +++ b/fpicker/source/aqua/FilterHelper.hxx @@ -27,6 +27,7 @@ #include #include +#include #include #include @@ -82,7 +83,7 @@ public: //XFilterManager delegates /// @throws css::lang::IllegalArgumentException /// @throws css::uno::RuntimeException - void appendFilter( const OUString& aTitle, const OUString& aFilter ); + void appendFilter( const OUString& aTitle, std::u16string_view aFilter ); /// @throws css::lang::IllegalArgumentException /// @throws css::uno::RuntimeException diff --git a/fpicker/source/aqua/FilterHelper.mm b/fpicker/source/aqua/FilterHelper.mm index fc6bca998755..f11d8447d91a 100644 --- a/fpicker/source/aqua/FilterHelper.mm +++ b/fpicker/source/aqua/FilterHelper.mm @@ -21,6 +21,9 @@ #include #include +#include +#include +#include #include #include @@ -31,12 +34,12 @@ namespace { -void fillSuffixList(OUStringList& aSuffixList, const OUString& suffixString) { - sal_Int32 nIndex = 0; +void fillSuffixList(OUStringList& aSuffixList, std::u16string_view suffixString) { + std::size_t nIndex = 0; do { - OUString aToken = suffixString.getToken( 0, ';', nIndex ); - aSuffixList.push_back(aToken.copy(1)); - } while ( nIndex >= 0 ); + std::u16string_view aToken = o3tl::getToken( suffixString, u';', nIndex ); + aSuffixList.push_back(OUString(aToken.substr(1))); + } while ( nIndex != std::u16string_view::npos ); } } @@ -70,24 +73,22 @@ sal_Int32 FilterEntry::getSubFilters( UnoFilterList& _rSubFilterList ) #pragma mark statics static bool -isFilterString( const OUString& rFilterString, const char *pMatch ) +isFilterString( std::u16string_view rFilterString, std::u16string_view pMatch ) { - sal_Int32 nIndex = 0; - OUString aToken; + std::size_t nIndex = 0; + std::u16string_view aToken; bool bIsFilter = true; - OUString aMatch(OUString::createFromAscii(pMatch)); - do { - aToken = rFilterString.getToken( 0, ';', nIndex ); - if( !aToken.match( aMatch ) ) + aToken = o3tl::getToken( rFilterString, u';', nIndex ); + if( !o3tl::starts_with( aToken, pMatch ) ) { bIsFilter = false; break; } } - while( nIndex >= 0 ); + while( nIndex != std::u16string_view::npos ); return bIsFilter; } @@ -109,11 +110,11 @@ shrinkFilterName( const OUString& aFilterName, bool bAllowNoStar = false ) sal_Int32 nBracketLen = nBracketEnd - i; if( nBracketEnd <= 0 ) continue; - if( isFilterString( aFilterName.copy( i + 1, nBracketLen - 1 ), "*." ) ) + if( isFilterString( aFilterName.subView( i + 1, nBracketLen - 1 ), u"*." ) ) aRealName = aRealName.replaceAt( i, nBracketLen + 1, u"" ); else if (bAllowNoStar) { - if( isFilterString( aFilterName.copy( i + 1, nBracketLen - 1 ), ".") ) + if( isFilterString( aFilterName.subView( i + 1, nBracketLen - 1 ), u".") ) aRealName = aRealName.replaceAt( i, nBracketLen + 1, u"" ); } } @@ -259,7 +260,7 @@ void FilterHelper::SetFilters() } } -void FilterHelper::appendFilter(const OUString& aTitle, const OUString& aFilterString) +void FilterHelper::appendFilter(const OUString& aTitle, std::u16string_view aFilterString) { SolarMutexGuard aGuard; -- cgit