summaryrefslogtreecommitdiffstats
path: root/include/rtl
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2021-07-16 14:48:25 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2021-07-17 09:12:26 +0200
commitb1df9c67349cf4cc5be4128d797aefb87f50e38f (patch)
tree171fbccaadecd8fac85e1e6212ce560162fabc7f /include/rtl
parentosl::Mutex->std::mutex in OWeakConnectionPoint (diff)
downloadcore-b1df9c67349cf4cc5be4128d797aefb87f50e38f.tar.gz
core-b1df9c67349cf4cc5be4128d797aefb87f50e38f.zip
[API CHANGE] reduce cost of numeric conversion
on a hot path, since we already know the length of these strings. Which requires adding some new variants of our string conversion functions Change-Id: I1877f8f3c72934c07f14eec7e73bbe8d7b0f1808 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119065 Tested-by: Noel Grandin <noel.grandin@collabora.co.uk> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'include/rtl')
-rw-r--r--include/rtl/string.h45
1 files changed, 45 insertions, 0 deletions
diff --git a/include/rtl/string.h b/include/rtl/string.h
index d29caf93a718..62fc7ecfb2d0 100644
--- a/include/rtl/string.h
+++ b/include/rtl/string.h
@@ -747,6 +747,31 @@ SAL_DLLPUBLIC sal_Bool SAL_CALL rtl_str_toBoolean(
SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_str_toInt32(
const char * str, sal_Int16 radix ) SAL_THROW_EXTERN_C();
+/** Interpret a string as a integer.
+
+ This function cannot be used for language-specific conversion. The string
+ must be null-terminated.
+
+ @param str
+ a null-terminated string.
+
+ @param radix
+ the radix. Must be between RTL_STR_MIN_RADIX (2) and RTL_STR_MAX_RADIX
+ (36), inclusive.
+
+ @param nStrLength
+ number of chars to process
+
+ @return
+ the integer value represented by the string, or 0 if the string does
+ not represent a integer.
+
+ @internal
+ @since LibreOffice 7.3
+*/
+SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_str_toInt32_WithLength(
+ const char * str, sal_Int16 radix, sal_Int32 nStrLength ) SAL_THROW_EXTERN_C();
+
/** Interpret a string as an unsigned integer.
This function cannot be used for language-specific conversion. The string
@@ -863,6 +888,26 @@ SAL_DLLPUBLIC float SAL_CALL rtl_str_toFloat(
SAL_DLLPUBLIC double SAL_CALL rtl_str_toDouble(
const char * str ) SAL_THROW_EXTERN_C();
+/** Interpret a string as a double.
+
+ This function cannot be used for language-specific conversion. The string
+ must be null-terminated.
+
+ @param str
+ a null-terminated string.
+
+ @param nStrLength
+ number of chars to process
+
+ @return
+ the double value represented by the string, or 0.0 if the string does not
+ represent a double.
+
+ @since LibreOffice 7.3
+ */
+SAL_DLLPUBLIC double SAL_CALL rtl_str_toDouble_WithLength(
+ const char * str, sal_Int32 nStrLength ) SAL_THROW_EXTERN_C();
+
/* ======================================================================= */
#ifdef _WIN32