diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-04-26 21:03:10 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-04-27 14:02:16 +0200 |
commit | 05e75d86dbac70486306b2d8bccd88fbc51d2906 (patch) | |
tree | 6cd054b01eb5675b5a56260a6649bdb6dc22e09a /tools | |
parent | 3791aff7ba4481cc4a357b7223440bf785469bb3 (diff) |
use more string_view in tools
Change-Id: I15ca12f35a66994cb90a0ccf60a1ce0f8efcfecc
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133459
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/source/generic/bigint.cxx | 11 | ||||
-rw-r--r-- | tools/source/memtools/multisel.cxx | 21 |
2 files changed, 19 insertions, 13 deletions
diff --git a/tools/source/generic/bigint.cxx b/tools/source/generic/bigint.cxx index f6627200a61c..51810cab17c2 100644 --- a/tools/source/generic/bigint.cxx +++ b/tools/source/generic/bigint.cxx @@ -475,20 +475,25 @@ BigInt::BigInt( const BigInt& rBigInt ) nVal = rBigInt.nVal; } -BigInt::BigInt( const OUString& rString ) +BigInt::BigInt( std::u16string_view rString ) : nLen(0) { bIsNeg = false; nVal = 0; bool bNeg = false; - const sal_Unicode* p = rString.getStr(); + auto p = rString.begin(); + auto pEnd = rString.end(); + if (p == pEnd) + return; if ( *p == '-' ) { bNeg = true; p++; } - while( *p >= '0' && *p <= '9' ) + if (p == pEnd) + return; + while( p != pEnd && *p >= '0' && *p <= '9' ) { *this *= 10; *this += *p - '0'; diff --git a/tools/source/memtools/multisel.cxx b/tools/source/memtools/multisel.cxx index 1f3f8eb5a23a..c6dd9d8c3146 100644 --- a/tools/source/memtools/multisel.cxx +++ b/tools/source/memtools/multisel.cxx @@ -468,7 +468,7 @@ void MultiSelection::SetTotalRange( const Range& rTotRange ) // StringRangeEnumerator -StringRangeEnumerator::StringRangeEnumerator( const OUString& i_rInput, +StringRangeEnumerator::StringRangeEnumerator( std::u16string_view i_rInput, sal_Int32 i_nMinNumber, sal_Int32 i_nMaxNumber, sal_Int32 i_nLogicalOffset @@ -566,18 +566,19 @@ void StringRangeEnumerator::insertJoinedRanges( } } -bool StringRangeEnumerator::setRange( const OUString& i_rNewRange ) +bool StringRangeEnumerator::setRange( std::u16string_view aNewRange ) { mnCount = 0; maSequence.clear(); - const sal_Unicode* pInput = i_rNewRange.getStr(); + auto pInput = aNewRange.begin(); + auto pInputEnd = aNewRange.end(); OUStringBuffer aNumberBuf( 16 ); std::vector< sal_Int32 > aNumbers; bool bSequence = false; - while( *pInput ) + while( pInput != pInputEnd ) { - while( *pInput >= '0' && *pInput <= '9' ) + while( pInput != pInputEnd && *pInput >= '0' && *pInput <= '9' ) aNumberBuf.append( *pInput++ ); if( !aNumberBuf.isEmpty() ) { @@ -585,7 +586,8 @@ bool StringRangeEnumerator::setRange( const OUString& i_rNewRange ) aNumbers.push_back( nNumber ); bSequence = false; } - + if (pInput == pInputEnd) + break; if( *pInput == '-' ) { bSequence = true; @@ -607,11 +609,10 @@ bool StringRangeEnumerator::setRange( const OUString& i_rNewRange ) aNumbers.clear(); bSequence = false; } - else if( *pInput && *pInput != ' ' ) + else if( *pInput != ' ' ) return false; // parse error - if( *pInput ) - pInput++; + pInput++; } // insert last entries if( bSequence && !aNumbers.empty() ) @@ -710,7 +711,7 @@ StringRangeEnumerator::Iterator StringRangeEnumerator::end( const o3tl::sorted_v return StringRangeEnumerator::Iterator( this, i_pPossibleValues, -1, -1 ); } -bool StringRangeEnumerator::getRangesFromString( const OUString& i_rPageRange, +bool StringRangeEnumerator::getRangesFromString( std::u16string_view i_rPageRange, std::vector< sal_Int32 >& o_rPageVector, sal_Int32 i_nMinNumber, sal_Int32 i_nMaxNumber, |