connectivity/source/resource/sharedresources.cxx |   15 ++++-----------
 1 file changed, 4 insertions(+), 11 deletions(-)

New commits:
commit 3a1b2c2b01bba0f1aeff52067110c44b68cd31be
Author:     Julien Nabet <serval2...@yahoo.fr>
AuthorDate: Mon Sep 5 21:47:53 2022 +0200
Commit:     Julien Nabet <serval2...@yahoo.fr>
CommitDate: Thu Sep 8 18:57:50 2022 +0200

    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 <serval2...@yahoo.fr>

diff --git a/connectivity/source/resource/sharedresources.cxx 
b/connectivity/source/resource/sharedresources.cxx
index 0f8bccefd96b..cc6f65e64541 100644
--- a/connectivity/source/resource/sharedresources.cxx
+++ b/connectivity/source/resource/sharedresources.cxx
@@ -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;
         }
     }
 

Reply via email to