diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-04-01 17:42:34 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-04-02 13:31:19 +0200 |
commit | 1927b51993fb68907a75765676179b08ab195196 (patch) | |
tree | 1b7d09c1b5e7ea945fb6ea618a4c100e8630ebb4 /basctl/source | |
parent | 0dfa444f393a5766d36fe7d2480d0c8ec832e329 (diff) |
loplugin:stringviewparam convert methods using indexOf
.. and lastIndexOf, which convert to find and rfind
Change-Id: I6c4156cf904774c0d867f85a4c2785dba7593f62
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132445
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'basctl/source')
-rw-r--r-- | basctl/source/basicide/baside2b.cxx | 18 | ||||
-rw-r--r-- | basctl/source/inc/bastypes.hxx | 2 |
2 files changed, 7 insertions, 13 deletions
diff --git a/basctl/source/basicide/baside2b.cxx b/basctl/source/basicide/baside2b.cxx index e15ccc3ef3ed..262f9e49a248 100644 --- a/basctl/source/basicide/baside2b.cxx +++ b/basctl/source/basicide/baside2b.cxx @@ -971,20 +971,14 @@ void EditorWindow::SetSourceInBasic() // Returns the position of the last character of any of the following // EOL char combinations: CR, CR/LF, LF, return -1 if no EOL is found -sal_Int32 searchEOL( const OUString& rStr, sal_Int32 fromIndex ) +sal_Int32 searchEOL( std::u16string_view rStr, sal_Int32 fromIndex ) { - sal_Int32 iRetPos = -1; + size_t iLF = rStr.find( LINE_SEP, fromIndex ); + if( iLF != std::u16string_view::npos ) + return iLF; - sal_Int32 iLF = rStr.indexOf( LINE_SEP, fromIndex ); - if( iLF != -1 ) - { - iRetPos = iLF; - } - else - { - iRetPos = rStr.indexOf( LINE_SEP_CR, fromIndex ); - } - return iRetPos; + size_t iCR = rStr.find( LINE_SEP_CR, fromIndex ); + return iCR == std::u16string_view::npos ? -1 : iCR; } void EditorWindow::CreateEditEngine() diff --git a/basctl/source/inc/bastypes.hxx b/basctl/source/inc/bastypes.hxx index f2e989aeb145..520d1a711992 100644 --- a/basctl/source/inc/bastypes.hxx +++ b/basctl/source/inc/bastypes.hxx @@ -53,7 +53,7 @@ constexpr auto LINE_SEP_CR = 0x0D; constexpr auto LINE_SEP = 0x0A; // Implementation: baside2b.cxx -sal_Int32 searchEOL( const OUString& rStr, sal_Int32 fromIndex ); +sal_Int32 searchEOL( std::u16string_view rStr, sal_Int32 fromIndex ); // Meaning of bToBeKilled: // While being in a reschedule-loop, I may not destroy the window. |