summaryrefslogtreecommitdiff
path: root/sal/rtl
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2023-04-02 15:01:31 +0200
committerMike Kaganski <mike.kaganski@collabora.com>2023-04-02 16:24:12 +0200
commitebf2cc4e9dacdc7afdeb4fcc91482678fa3edc4a (patch)
tree83e9e8eaf34783d604688e3b2d00faf3f7c59b68 /sal/rtl
parentce86e5b4a8d54eb55fdde7756ad6fde6e6967d55 (diff)
Simplify a bit
Change-Id: Iae784d3ae40cd237c768413c067a2067c608238d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149885 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'sal/rtl')
-rw-r--r--sal/rtl/strtmpl.hxx14
1 files changed, 3 insertions, 11 deletions
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;
}
/* ----------------------------------------------------------------------- */