summaryrefslogtreecommitdiff
path: root/sal
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2022-04-10 09:31:16 +0100
committerMike Kaganski <mike.kaganski@collabora.com>2022-04-10 18:40:52 +0200
commit57f22d9b1a4e1cd161a35c8e4c390661db981d2c (patch)
treeda5b27040ca88c5db34c86ef658e526068ef0012 /sal
parent35bf17d758e67c939b8abcc5355e674030e135ac (diff)
Move impl functions to the only place they are used
Change-Id: I6871bfc0ae3d2427a4cd135cb37aad76dac0d7a4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132706 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'sal')
-rw-r--r--sal/rtl/strimp.cxx30
-rw-r--r--sal/rtl/strimp.hxx4
-rw-r--r--sal/rtl/strtmpl.hxx38
3 files changed, 34 insertions, 38 deletions
diff --git a/sal/rtl/strimp.cxx b/sal/rtl/strimp.cxx
index 51a1a94bd705..44b56023d0d4 100644
--- a/sal/rtl/strimp.cxx
+++ b/sal/rtl/strimp.cxx
@@ -27,36 +27,6 @@
#include "alloc_impl.hxx"
#include "alloc_arena.hxx"
-sal_Int16 rtl_ImplGetDigit( sal_Unicode ch, sal_Int16 nRadix )
-{
- sal_Int16 n = -1;
- if ( (ch >= '0') && (ch <= '9') )
- n = ch-'0';
- else if ( (ch >= 'a') && (ch <= 'z') )
- n = ch-'a'+10;
- else if ( (ch >= 'A') && (ch <= 'Z') )
- n = ch-'A'+10;
- return (n < nRadix) ? n : -1;
-}
-
-bool rtl_ImplIsWhitespace( sal_Unicode c )
-{
- /* Space or Control character? */
- if ( (c <= 32) && c )
- return true;
-
- /* Only in the General Punctuation area Space or Control characters are included? */
- if ( (c < 0x2000) || (c > 0x206F) )
- return false;
-
- if ( ((c >= 0x2000) && (c <= 0x200B)) || /* All Spaces */
- (c == 0x2028) || /* LINE SEPARATOR */
- (c == 0x2029) ) /* PARAGRAPH SEPARATOR */
- return true;
-
- return false;
-}
-
/*
* TODO: add a slower, more awful, but more space efficient
* custom allocator for the pre-init phase. Existing slab
diff --git a/sal/rtl/strimp.hxx b/sal/rtl/strimp.hxx
index f3516f7999bd..69404e0aa390 100644
--- a/sal/rtl/strimp.hxx
+++ b/sal/rtl/strimp.hxx
@@ -46,10 +46,6 @@
#define SAL_STRING_IS_INTERN(a) ((a)->refCount & SAL_STRING_INTERN_FLAG)
#define SAL_STRING_IS_STATIC(a) ((a)->refCount & SAL_STRING_STATIC_FLAG)
-sal_Int16 rtl_ImplGetDigit( sal_Unicode ch, sal_Int16 nRadix );
-
-bool rtl_ImplIsWhitespace( sal_Unicode c );
-
rtl_uString* rtl_uString_ImplAlloc( sal_Int32 nLen );
rtl_String* rtl_string_ImplAlloc( sal_Int32 nLen );
diff --git a/sal/rtl/strtmpl.hxx b/sal/rtl/strtmpl.hxx
index 341c6717f39e..e1389ce6ad1b 100644
--- a/sal/rtl/strtmpl.hxx
+++ b/sal/rtl/strtmpl.hxx
@@ -139,6 +139,36 @@ inline void Copy(sal_Unicode* _pDest, const char* _pSrc, sal_Int32 _nCount)
});
}
+inline sal_Int16 implGetDigit(sal_Unicode ch, sal_Int16 nRadix)
+{
+ sal_Int16 n = -1;
+ if ((ch >= '0') && (ch <= '9'))
+ n = ch - '0';
+ else if ((ch >= 'a') && (ch <= 'z'))
+ n = ch - 'a' + 10;
+ else if ((ch >= 'A') && (ch <= 'Z'))
+ n = ch - 'A' + 10;
+ return (n < nRadix) ? n : -1;
+}
+
+inline bool implIsWhitespace(sal_Unicode c)
+{
+ /* Space or Control character? */
+ if ((c <= 32) && c)
+ return true;
+
+ /* Only in the General Punctuation area Space or Control characters are included? */
+ if ((c < 0x2000) || (c > 0x206F))
+ return false;
+
+ if (((c >= 0x2000) && (c <= 0x200B)) || /* All Spaces */
+ (c == 0x2028) || /* LINE SEPARATOR */
+ (c == 0x2029)) /* PARAGRAPH SEPARATOR */
+ return true;
+
+ return false;
+}
+
/* ======================================================================= */
/* C-String functions which could be used without the String-Class */
/* ======================================================================= */
@@ -549,10 +579,10 @@ std::basic_string_view<IMPL_RTL_STRCODE> trimView( IMPL_RTL_STRCODE* pStr, sal_I
sal_Int32 nPostSpaces = 0;
sal_Int32 nIndex = nLen-1;
- while ( (nPreSpaces < nLen) && rtl_ImplIsWhitespace( IMPL_RTL_USTRCODE(*(pStr+nPreSpaces)) ) )
+ while ( (nPreSpaces < nLen) && implIsWhitespace( IMPL_RTL_USTRCODE(*(pStr+nPreSpaces)) ) )
nPreSpaces++;
- while ( (nIndex > nPreSpaces) && rtl_ImplIsWhitespace( IMPL_RTL_USTRCODE(*(pStr+nIndex)) ) )
+ while ( (nIndex > nPreSpaces) && implIsWhitespace( IMPL_RTL_USTRCODE(*(pStr+nIndex)) ) )
{
nPostSpaces++;
nIndex--;
@@ -751,7 +781,7 @@ template <typename T, class S> T toInt(S str, sal_Int16 nRadix)
const auto end = str.end();
/* Skip whitespaces */
- while (pStr != end && rtl_ImplIsWhitespace(IMPL_RTL_USTRCODE(*pStr)))
+ while (pStr != end && implIsWhitespace(IMPL_RTL_USTRCODE(*pStr)))
pStr++;
if (pStr == end)
return 0;
@@ -763,7 +793,7 @@ template <typename T, class S> T toInt(S str, sal_Int16 nRadix)
std::make_unsigned_t<T> n = 0;
while (pStr != end)
{
- sal_Int16 nDigit = rtl_ImplGetDigit(IMPL_RTL_USTRCODE(*pStr), nRadix);
+ sal_Int16 nDigit = implGetDigit(IMPL_RTL_USTRCODE(*pStr), nRadix);
if ( nDigit < 0 )
break;
if (static_cast<std::make_unsigned_t<T>>(nMod < nDigit ? nDiv - 1 : nDiv) < n)