Simplify by using replace instead of replaceAt in loop in connectivity (3)
Change-Id: If7517356959d4720bbe07acea822ec835a681a17 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139456 Tested-by: Jenkins Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
This commit is contained in:
parent
4182f3cda4
commit
3a1b2c2b01
1 changed files with 4 additions and 11 deletions
|
@ -100,20 +100,13 @@ namespace connectivity
|
|||
|
||||
namespace
|
||||
{
|
||||
size_t lcl_substitute( OUString& _inout_rString,
|
||||
bool lcl_substitute( OUString& _inout_rString,
|
||||
const char* _pAsciiPattern, std::u16string_view _rReplace )
|
||||
{
|
||||
size_t nOccurrences = 0;
|
||||
|
||||
OUString oldString = _inout_rString;
|
||||
OUString sPattern( OUString::createFromAscii( _pAsciiPattern ) );
|
||||
sal_Int32 nIndex = 0;
|
||||
while ( ( nIndex = _inout_rString.indexOf( sPattern ) ) > -1 )
|
||||
{
|
||||
++nOccurrences;
|
||||
_inout_rString = _inout_rString.replaceAt( nIndex, sPattern.getLength(), _rReplace );
|
||||
}
|
||||
|
||||
return nOccurrences;
|
||||
_inout_rString = _inout_rString.replaceAll(sPattern, _rReplace);
|
||||
return oldString != _inout_rString;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue