[Libreoffice-commits] core.git: sal/rtl

Stephan Bergmann sbergman at redhat.com
Tue Mar 26 15:29:04 PDT 2013


 sal/rtl/strtmpl.cxx |   70 +++++++++++++++++++++++-----------------------------
 1 file changed, 31 insertions(+), 39 deletions(-)

New commits:
commit b57951a6b372bd77a6207b67fa305270129fcb71
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Tue Mar 26 23:28:29 2013 +0100

    No need for a template here
    
    Change-Id: I43262c984c311fcb1e1a9eca9b4dec4092351dea

diff --git a/sal/rtl/strtmpl.cxx b/sal/rtl/strtmpl.cxx
index 455a6ae..78aa1f5 100644
--- a/sal/rtl/strtmpl.cxx
+++ b/sal/rtl/strtmpl.cxx
@@ -982,44 +982,6 @@ namespace {
         else
             return n;
     }
-
-
-    template <typename T> static inline T IMPL_RTL_STRNAME( toUInt )( const IMPL_RTL_STRCODE* pStr,
-                                                                      sal_Int16 nRadix )
-    {
-        BOOST_STATIC_ASSERT(!std::numeric_limits<T>::is_signed);
-        sal_Int16   nDigit;
-        T           n = 0;
-
-        if ( (nRadix < RTL_STR_MIN_RADIX) || (nRadix > RTL_STR_MAX_RADIX) )
-            nRadix = 10;
-
-        /* Skip whitespaces */
-        while ( *pStr && rtl_ImplIsWhitespace( IMPL_RTL_USTRCODE( *pStr ) ) )
-            ++pStr;
-
-        // skip optional explicit sign
-        if ( *pStr == '+' )
-            ++pStr;
-
-        const T nDiv = std::numeric_limits<T>::max()/nRadix;
-        const sal_Int16 nMod = std::numeric_limits<T>::max()%nRadix;
-        while ( *pStr )
-        {
-            nDigit = rtl_ImplGetDigit( IMPL_RTL_USTRCODE( *pStr ), nRadix );
-            if ( nDigit < 0 )
-                break;
-            if( ( nMod < nDigit ? nDiv-1 : nDiv ) < n )
-                return 0;
-
-            n *= nRadix;
-            n += nDigit;
-
-            ++pStr;
-        }
-
-        return n;
-    }
 }
 
 sal_Int32 SAL_CALL IMPL_RTL_STRNAME( toInt32 )( const IMPL_RTL_STRCODE* pStr,
@@ -1042,7 +1004,37 @@ sal_uInt64 SAL_CALL IMPL_RTL_STRNAME( toUInt64 )( const IMPL_RTL_STRCODE* pStr,
                                                   sal_Int16 nRadix )
     SAL_THROW_EXTERN_C()
 {
-    return IMPL_RTL_STRNAME( toUInt )<sal_uInt64>(pStr, nRadix);
+    sal_Int16   nDigit;
+    sal_uInt64  n = 0;
+
+    if ( (nRadix < RTL_STR_MIN_RADIX) || (nRadix > RTL_STR_MAX_RADIX) )
+        nRadix = 10;
+
+    /* Skip whitespaces */
+    while ( *pStr && rtl_ImplIsWhitespace( IMPL_RTL_USTRCODE( *pStr ) ) )
+        ++pStr;
+
+    // skip optional explicit sign
+    if ( *pStr == '+' )
+        ++pStr;
+
+    const sal_uInt64 nDiv = SAL_MAX_UINT64/nRadix;
+    const sal_Int16 nMod = SAL_MAX_UINT64%nRadix;
+    while ( *pStr )
+    {
+        nDigit = rtl_ImplGetDigit( IMPL_RTL_USTRCODE( *pStr ), nRadix );
+        if ( nDigit < 0 )
+            break;
+        if( ( nMod < nDigit ? nDiv-1 : nDiv ) < n )
+            return 0;
+
+        n *= nRadix;
+        n += nDigit;
+
+        ++pStr;
+    }
+
+    return n;
 }
 
 /* ======================================================================= */


More information about the Libreoffice-commits mailing list