diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-10-14 14:29:51 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-10-17 10:39:11 +0200 |
commit | 425255567eafffba3a5817fb96050663d1db8e2f (patch) | |
tree | d4f78a9103c34367b2aa29feb31faf4e6871d01e /scripting | |
parent | 6125be0aa10113d840a1fdbe33cf3174d5896fcb (diff) |
use more string_view
Change-Id: Ie826234aa9064b08b8f0647738b57c47ac0ed91a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141369
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'scripting')
-rw-r--r-- | scripting/source/provider/MasterScriptProvider.cxx | 8 | ||||
-rw-r--r-- | scripting/source/stringresource/stringresource.cxx | 27 |
2 files changed, 18 insertions, 17 deletions
diff --git a/scripting/source/provider/MasterScriptProvider.cxx b/scripting/source/provider/MasterScriptProvider.cxx index 190382cee69b..66fc58db78bd 100644 --- a/scripting/source/provider/MasterScriptProvider.cxx +++ b/scripting/source/provider/MasterScriptProvider.cxx @@ -51,11 +51,11 @@ using namespace ::sf_misc; namespace func_provider { -static bool endsWith( const OUString& target, const OUString& item ) +static bool endsWith( std::u16string_view target, std::u16string_view item ) { - sal_Int32 index = target.indexOf( item ); - return index != -1 && - index == ( target.getLength() - item.getLength() ); + size_t index = target.find( item ); + return index != std::u16string_view::npos && + index == ( target.size() - item.size() ); } /* should be available in some central location. */ diff --git a/scripting/source/stringresource/stringresource.cxx b/scripting/source/stringresource/stringresource.cxx index 06b52b0377c7..669da8b2cbba 100644 --- a/scripting/source/stringresource/stringresource.cxx +++ b/scripting/source/stringresource/stringresource.cxx @@ -33,6 +33,7 @@ #include <com/sun/star/ucb/SimpleFileAccess.hpp> #include <osl/diagnose.h> +#include <o3tl/string_view.hxx> #include <rtl/tencinfo.h> #include <rtl/ustrbuf.hxx> #include <tools/urlobj.hxx> @@ -1437,17 +1438,17 @@ void StringResourcePersistenceImpl::importBinary( const Sequence< ::sal_Int8 >& // Private helper methods -static bool checkNamingSceme( const OUString& aName, const OUString& aNameBase, +static bool checkNamingSceme( std::u16string_view aName, std::u16string_view aNameBase, Locale& aLocale ) { bool bSuccess = false; - sal_Int32 nNameLen = aName.getLength(); - sal_Int32 nNameBaseLen = aNameBase.getLength(); + size_t nNameLen = aName.size(); + size_t nNameBaseLen = aNameBase.size(); // Name has to start with NameBase followed // by a '_' and at least one more character - if( aName.startsWith( aNameBase ) && nNameBaseLen < nNameLen-1 && + if( o3tl::starts_with(aName, aNameBase) && nNameBaseLen < nNameLen-1 && aName[nNameBaseLen] == '_' ) { bSuccess = true; @@ -1457,23 +1458,23 @@ static bool checkNamingSceme( const OUString& aName, const OUString& aNameBase, * violate the naming scheme in use. */ sal_Int32 iStart = nNameBaseLen + 1; - sal_Int32 iNext_ = aName.indexOf( '_', iStart ); - if( iNext_ != -1 && iNext_ < nNameLen-1 ) + size_t iNext_ = aName.find( '_', iStart ); + if( iNext_ != std::u16string_view::npos && iNext_ < nNameLen-1 ) { - aLocale.Language = aName.copy( iStart, iNext_ - iStart ); + aLocale.Language = aName.substr( iStart, iNext_ - iStart ); iStart = iNext_ + 1; - iNext_ = aName.indexOf( '_', iStart ); - if( iNext_ != -1 && iNext_ < nNameLen-1 ) + iNext_ = aName.find( '_', iStart ); + if( iNext_ != std::u16string_view::npos && iNext_ < nNameLen-1 ) { - aLocale.Country = aName.copy( iStart, iNext_ - iStart ); - aLocale.Variant = aName.copy( iNext_ + 1 ); + aLocale.Country = aName.substr( iStart, iNext_ - iStart ); + aLocale.Variant = aName.substr( iNext_ + 1 ); } else - aLocale.Country = aName.copy( iStart ); + aLocale.Country = aName.substr( iStart ); } else - aLocale.Language = aName.copy( iStart ); + aLocale.Language = aName.substr( iStart ); } return bSuccess; } |