summaryrefslogtreecommitdiff
path: root/comphelper
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2022-04-10 15:36:21 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2022-04-10 20:15:16 +0200
commitb24a4d255d31233c48152e6e1ce992a693cdaeae (patch)
treee0ad8f574d3b1ddcad3d81ec3ac438777ca4846d /comphelper
parent57f22d9b1a4e1cd161a35c8e4c390661db981d2c (diff)
use more string_view
found by tweaking the loplugin:stringview and making it whitelist getLength Change-Id: Ic15d3703d1fb07658e99e1db1c89e2fa5bc70c19 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132771 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'comphelper')
-rw-r--r--comphelper/source/misc/accessibletexthelper.cxx4
-rw-r--r--comphelper/source/misc/docpasswordhelper.cxx6
-rw-r--r--comphelper/source/misc/mimeconfighelper.cxx8
-rw-r--r--comphelper/source/misc/storagehelper.cxx17
4 files changed, 18 insertions, 17 deletions
diff --git a/comphelper/source/misc/accessibletexthelper.cxx b/comphelper/source/misc/accessibletexthelper.cxx
index 35fe769c1700..0678456192d7 100644
--- a/comphelper/source/misc/accessibletexthelper.cxx
+++ b/comphelper/source/misc/accessibletexthelper.cxx
@@ -215,9 +215,9 @@ namespace comphelper
}
- sal_Unicode OCommonAccessibleText::implGetCharacter( const OUString& rText, sal_Int32 nIndex )
+ sal_Unicode OCommonAccessibleText::implGetCharacter( std::u16string_view rText, sal_Int32 nIndex )
{
- if ( !implIsValidIndex( nIndex, rText.getLength() ) )
+ if ( !implIsValidIndex( nIndex, rText.size() ) )
throw IndexOutOfBoundsException();
return rText[nIndex];
diff --git a/comphelper/source/misc/docpasswordhelper.cxx b/comphelper/source/misc/docpasswordhelper.cxx
index 436b599f9e1f..e32c3d8b1303 100644
--- a/comphelper/source/misc/docpasswordhelper.cxx
+++ b/comphelper/source/misc/docpasswordhelper.cxx
@@ -197,7 +197,7 @@ bool DocPasswordHelper::IsModifyPasswordCorrect( std::u16string_view aPassword,
sal_uInt32 DocPasswordHelper::GetWordHashAsUINT32(
- const OUString& aUString )
+ std::u16string_view aUString )
{
static const sal_uInt16 pInitialCode[] = {
0xE1F0, // 1
@@ -236,7 +236,7 @@ sal_uInt32 DocPasswordHelper::GetWordHashAsUINT32(
};
sal_uInt32 nResult = 0;
- sal_uInt32 nLen = aUString.getLength();
+ size_t nLen = aUString.size();
if ( nLen )
{
@@ -246,7 +246,7 @@ sal_uInt32 DocPasswordHelper::GetWordHashAsUINT32(
sal_uInt16 nHighResult = pInitialCode[nLen - 1];
sal_uInt16 nLowResult = 0;
- for ( sal_uInt32 nInd = 0; nInd < nLen; nInd++ )
+ for ( size_t nInd = 0; nInd < nLen; nInd++ )
{
// NO Encoding during conversion!
// The specification says that the low byte should be used in case it is not NULL
diff --git a/comphelper/source/misc/mimeconfighelper.cxx b/comphelper/source/misc/mimeconfighelper.cxx
index 8ec72e271f55..0046c7f11d4f 100644
--- a/comphelper/source/misc/mimeconfighelper.cxx
+++ b/comphelper/source/misc/mimeconfighelper.cxx
@@ -81,18 +81,18 @@ static sal_uInt8 GetDigit_Impl( char aChar )
}
-uno::Sequence< sal_Int8 > MimeConfigurationHelper::GetSequenceClassIDRepresentation( const OUString& aClassID )
+uno::Sequence< sal_Int8 > MimeConfigurationHelper::GetSequenceClassIDRepresentation( std::u16string_view aClassID )
{
- sal_Int32 nLength = aClassID.getLength();
+ size_t nLength = aClassID.size();
if ( nLength == 36 )
{
OString aCharClassID = OUStringToOString( aClassID, RTL_TEXTENCODING_ASCII_US );
uno::Sequence< sal_Int8 > aResult( 16 );
auto pResult = aResult.getArray();
- sal_Int32 nStrPointer = 0;
+ size_t nStrPointer = 0;
sal_Int32 nSeqInd = 0;
- while( nSeqInd < 16 && nStrPointer + 1 < nLength )
+ while( nSeqInd < 16 && nStrPointer + 1U < nLength )
{
sal_uInt8 nDigit1 = GetDigit_Impl( aCharClassID[nStrPointer++] );
sal_uInt8 nDigit2 = GetDigit_Impl( aCharClassID[nStrPointer++] );
diff --git a/comphelper/source/misc/storagehelper.cxx b/comphelper/source/misc/storagehelper.cxx
index 13e9eb3aa288..b850d7d70197 100644
--- a/comphelper/source/misc/storagehelper.cxx
+++ b/comphelper/source/misc/storagehelper.cxx
@@ -56,6 +56,7 @@
#include <comphelper/storagehelper.hxx>
#include <comphelper/sequence.hxx>
#include <cppuhelper/exc_hlp.hxx>
+#include <o3tl/string_view.hxx>
#if HAVE_FEATURE_GPGME
# include <context.h>
@@ -561,27 +562,27 @@ bool OStorageHelper::IsValidZipEntryFileName(
}
-bool OStorageHelper::PathHasSegment( const OUString& aPath, const OUString& aSegment )
+bool OStorageHelper::PathHasSegment( std::u16string_view aPath, std::u16string_view aSegment )
{
bool bResult = false;
- const sal_Int32 nPathLen = aPath.getLength();
- const sal_Int32 nSegLen = aSegment.getLength();
+ const size_t nPathLen = aPath.size();
+ const size_t nSegLen = aSegment.size();
- if ( !aSegment.isEmpty() && nPathLen >= nSegLen )
+ if ( !aSegment.empty() && nPathLen >= nSegLen )
{
- OUString aEndSegment = "/" + aSegment;
+ OUString aEndSegment = OUString::Concat("/") + aSegment;
OUString aInternalSegment = aEndSegment + "/";
- if ( aPath.indexOf( aInternalSegment ) >= 0 )
+ if ( aPath.find( aInternalSegment ) != std::u16string_view::npos )
bResult = true;
- if ( !bResult && aPath.startsWith( aSegment ) )
+ if ( !bResult && o3tl::starts_with(aPath, aSegment ) )
{
if ( nPathLen == nSegLen || aPath[nSegLen] == '/' )
bResult = true;
}
- if ( !bResult && nPathLen > nSegLen && aPath.subView( nPathLen - nSegLen - 1, nSegLen + 1 ) == aEndSegment )
+ if ( !bResult && nPathLen > nSegLen && aPath.substr( nPathLen - nSegLen - 1, nSegLen + 1 ) == aEndSegment )
bResult = true;
}