summaryrefslogtreecommitdiff
path: root/svl
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2022-04-11 14:49:08 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2022-04-11 17:44:46 +0200
commit6fc3dfd3f1b5cb13101299df42444f2ff0493846 (patch)
tree404a816727baa934e77c6e474cc57e83a7aa2754 /svl
parent8cbb08de38fc1a2f9d2ea0dfbdc2be8e8110ff73 (diff)
use more string_view
found by tweaking the loplugin:stringview and making it whitelist getLength Change-Id: Ic41cd4e3026d93b70a76fe1279c6de3abbe6b4a0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132820 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'svl')
-rw-r--r--svl/source/crypto/cryptosign.cxx4
-rw-r--r--svl/source/misc/PasswordHelper.cxx12
-rw-r--r--svl/source/misc/lngmisc.cxx4
-rw-r--r--svl/source/misc/urihelper.cxx4
-rw-r--r--svl/source/passwordcontainer/passwordcontainer.cxx8
-rw-r--r--svl/source/passwordcontainer/passwordcontainer.hxx2
6 files changed, 17 insertions, 17 deletions
diff --git a/svl/source/crypto/cryptosign.cxx b/svl/source/crypto/cryptosign.cxx
index 4596eeb167dd..ff8120ede34a 100644
--- a/svl/source/crypto/cryptosign.cxx
+++ b/svl/source/crypto/cryptosign.cxx
@@ -879,10 +879,10 @@ static int AsHex(char ch)
return nRet;
}
-std::vector<unsigned char> DecodeHexString(const OString& rHex)
+std::vector<unsigned char> DecodeHexString(std::string_view rHex)
{
std::vector<unsigned char> aRet;
- size_t nHexLen = rHex.getLength();
+ size_t nHexLen = rHex.size();
{
int nByte = 0;
int nCount = 2;
diff --git a/svl/source/misc/PasswordHelper.cxx b/svl/source/misc/PasswordHelper.cxx
index 047d0b09b88b..41d7bf1ea68b 100644
--- a/svl/source/misc/PasswordHelper.cxx
+++ b/svl/source/misc/PasswordHelper.cxx
@@ -58,9 +58,9 @@ void SvPasswordHelper::GetHashPassword(uno::Sequence<sal_Int8>& rPassHash, const
}
}
-void SvPasswordHelper::GetHashPasswordLittleEndian(uno::Sequence<sal_Int8>& rPassHash, const OUString& sPass)
+void SvPasswordHelper::GetHashPasswordLittleEndian(uno::Sequence<sal_Int8>& rPassHash, std::u16string_view sPass)
{
- sal_Int32 nSize(sPass.getLength());
+ sal_Int32 nSize(sPass.size());
std::unique_ptr<char[]> pCharBuffer(new char[nSize * sizeof(sal_Unicode)]);
for (sal_Int32 i = 0; i < nSize; ++i)
@@ -74,9 +74,9 @@ void SvPasswordHelper::GetHashPasswordLittleEndian(uno::Sequence<sal_Int8>& rPas
rtl_secureZeroMemory(pCharBuffer.get(), nSize * sizeof(sal_Unicode));
}
-void SvPasswordHelper::GetHashPasswordBigEndian(uno::Sequence<sal_Int8>& rPassHash, const OUString& sPass)
+void SvPasswordHelper::GetHashPasswordBigEndian(uno::Sequence<sal_Int8>& rPassHash, std::u16string_view sPass)
{
- sal_Int32 nSize(sPass.getLength());
+ sal_Int32 nSize(sPass.size());
std::unique_ptr<char[]> pCharBuffer(new char[nSize * sizeof(sal_Unicode)]);
for (sal_Int32 i = 0; i < nSize; ++i)
@@ -90,12 +90,12 @@ void SvPasswordHelper::GetHashPasswordBigEndian(uno::Sequence<sal_Int8>& rPassHa
rtl_secureZeroMemory(pCharBuffer.get(), nSize * sizeof(sal_Unicode));
}
-void SvPasswordHelper::GetHashPassword(uno::Sequence<sal_Int8>& rPassHash, const OUString& sPass)
+void SvPasswordHelper::GetHashPassword(uno::Sequence<sal_Int8>& rPassHash, std::u16string_view sPass)
{
GetHashPasswordLittleEndian(rPassHash, sPass);
}
-bool SvPasswordHelper::CompareHashPassword(const uno::Sequence<sal_Int8>& rOldPassHash, const OUString& sNewPass)
+bool SvPasswordHelper::CompareHashPassword(const uno::Sequence<sal_Int8>& rOldPassHash, std::u16string_view sNewPass)
{
bool bResult = false;
diff --git a/svl/source/misc/lngmisc.cxx b/svl/source/misc/lngmisc.cxx
index 4224a14429a5..7ccf0aed7215 100644
--- a/svl/source/misc/lngmisc.cxx
+++ b/svl/source/misc/lngmisc.cxx
@@ -26,10 +26,10 @@
namespace linguistic
{
- sal_Int32 GetNumControlChars(const OUString &rTxt)
+ sal_Int32 GetNumControlChars(std::u16string_view rTxt)
{
sal_Int32 nCnt = 0;
- for (sal_Int32 i = 0; i < rTxt.getLength(); ++i)
+ for (size_t i = 0; i < rTxt.size(); ++i)
if (IsControlChar(rTxt[i]))
++nCnt;
return nCnt;
diff --git a/svl/source/misc/urihelper.cxx b/svl/source/misc/urihelper.cxx
index af92a9d41fe2..e5ddbc37a93e 100644
--- a/svl/source/misc/urihelper.cxx
+++ b/svl/source/misc/urihelper.cxx
@@ -282,10 +282,10 @@ OUString URIHelper::simpleNormalizedMakeRelative(
namespace {
-sal_Int32 nextChar(OUString const & rStr, sal_Int32 nPos)
+sal_Int32 nextChar(std::u16string_view rStr, sal_Int32 nPos)
{
return rtl::isHighSurrogate(rStr[nPos])
- && rStr.getLength() - nPos >= 2
+ && rStr.size() - nPos >= 2
&& rtl::isLowSurrogate(rStr[nPos + 1]) ?
nPos + 2 : nPos + 1;
}
diff --git a/svl/source/passwordcontainer/passwordcontainer.cxx b/svl/source/passwordcontainer/passwordcontainer.cxx
index 4dd36e732108..04eb0951f0ac 100644
--- a/svl/source/passwordcontainer/passwordcontainer.cxx
+++ b/svl/source/passwordcontainer/passwordcontainer.cxx
@@ -165,11 +165,11 @@ static OUString getAsciiLine( const ::rtl::ByteSequence& buf )
}
-static ::rtl::ByteSequence getBufFromAsciiLine( const OUString& line )
+static ::rtl::ByteSequence getBufFromAsciiLine( std::u16string_view line )
{
- OSL_ENSURE( line.getLength() % 2 == 0, "Wrong syntax!" );
+ OSL_ENSURE( line.size() % 2 == 0, "Wrong syntax!" );
OString tmpLine = OUStringToOString( line, RTL_TEXTENCODING_ASCII_US );
- ::rtl::ByteSequence aResult(line.getLength()/2);
+ ::rtl::ByteSequence aResult(line.size()/2);
for( int ind = 0; ind < tmpLine.getLength()/2; ind++ )
{
@@ -412,7 +412,7 @@ void SAL_CALL PasswordContainer::disposing( const EventObject& )
}
}
-std::vector< OUString > PasswordContainer::DecodePasswords( const OUString& aLine, const OUString& aIV, const OUString& aMasterPasswd, css::task::PasswordRequestMode mode )
+std::vector< OUString > PasswordContainer::DecodePasswords( std::u16string_view aLine, const OUString& aIV, const OUString& aMasterPasswd, css::task::PasswordRequestMode mode )
{
if( !aMasterPasswd.isEmpty() )
{
diff --git a/svl/source/passwordcontainer/passwordcontainer.hxx b/svl/source/passwordcontainer/passwordcontainer.hxx
index 8d77f0d2abf7..7924f53bff83 100644
--- a/svl/source/passwordcontainer/passwordcontainer.hxx
+++ b/svl/source/passwordcontainer/passwordcontainer.hxx
@@ -316,7 +316,7 @@ private:
const css::uno::Reference< css::task::XInteractionHandler >& Handler );
/// @throws css::uno::RuntimeException
- static ::std::vector< OUString > DecodePasswords( const OUString& aLine, const OUString& aIV, const OUString& aMasterPassword, css::task::PasswordRequestMode mode );
+ static ::std::vector< OUString > DecodePasswords( std::u16string_view aLine, const OUString& aIV, const OUString& aMasterPassword, css::task::PasswordRequestMode mode );
/// @throws css::uno::RuntimeException
static OUString EncodePasswords(const std::vector< OUString >& lines, const OUString& aIV, const OUString& aMasterPassword );