sal/rtl/strtmpl.hxx |   14 +++-----------
 1 file changed, 3 insertions(+), 11 deletions(-)

New commits:
commit ebf2cc4e9dacdc7afdeb4fcc91482678fa3edc4a
Author:     Mike Kaganski <mike.kagan...@collabora.com>
AuthorDate: Sun Apr 2 15:01:31 2023 +0200
Commit:     Mike Kaganski <mike.kagan...@collabora.com>
CommitDate: Sun Apr 2 16:24:12 2023 +0200

    Simplify a bit
    
    Change-Id: Iae784d3ae40cd237c768413c067a2067c608238d
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149885
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>

diff --git a/sal/rtl/strtmpl.hxx b/sal/rtl/strtmpl.hxx
index ef425a9b33ab..7ec3af82cf94 100644
--- a/sal/rtl/strtmpl.hxx
+++ b/sal/rtl/strtmpl.hxx
@@ -667,9 +667,9 @@ sal_Int32 valueOfInt                               ( 
IMPL_RTL_STRCODE* pStr,
 {
     assert(pStr);
     assert( nRadix >= RTL_STR_MIN_RADIX && nRadix <= RTL_STR_MAX_RADIX );
+    const auto* const pStart = pStr;
     char    aBuf[maxLen];
     char*   pBuf = aBuf;
-    sal_Int32   nLen = 0;
     using uT = std::make_unsigned_t<T>;
     uT nValue;
 
@@ -684,7 +684,6 @@ sal_Int32 valueOfInt                               ( 
IMPL_RTL_STRCODE* pStr,
         {
             *pStr = '-';
             pStr++;
-            nLen++;
             nValue = n == std::numeric_limits<T>::min() ? static_cast<uT>(n) : 
-n;
         }
         else
@@ -707,17 +706,10 @@ sal_Int32 valueOfInt                               ( 
IMPL_RTL_STRCODE* pStr,
     while ( nValue > 0 );
 
     /* copy the values in the right direction into the destination buffer */
-    do
-    {
-        pBuf--;
-        *pStr = *pBuf;
-        pStr++;
-        nLen++;
-    }
-    while ( pBuf != aBuf );
+    pStr = std::reverse_copy(aBuf, pBuf, pStr);
     *pStr = 0;
 
-    return nLen;
+    return pStr - pStart;
 }
 
 /* ----------------------------------------------------------------------- */

Reply via email to