From ab35d2ded153b0129fed16f9a7e882c8600933e6 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Wed, 30 Oct 2019 08:41:43 +0200 Subject: tdf#125688 speed up load of change-tracking ODS by 10%, by avoiding an OUString construction in a hot path through XMLTextColumnContext_Impl::XMLTextColumnContext_Impl -> sax::Convert::convertNumber Also changed XMLTextAnimationStepPropertyHdl::importXML to take advantage of the modified convertNumber passing convention. Change-Id: I4e5503dbb094c88a09af8b6dc8c22b6c53f9eb75 Reviewed-on: https://gerrit.libreoffice.org/81726 Tested-by: Jenkins Reviewed-by: Noel Grandin --- sal/rtl/strtmpl.cxx | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) (limited to 'sal/rtl') diff --git a/sal/rtl/strtmpl.cxx b/sal/rtl/strtmpl.cxx index 3cc4d9927274..4e6035d478e2 100644 --- a/sal/rtl/strtmpl.cxx +++ b/sal/rtl/strtmpl.cxx @@ -989,20 +989,23 @@ sal_Bool SAL_CALL IMPL_RTL_STRNAME( toBoolean )( const IMPL_RTL_STRCODE* pStr ) /* ----------------------------------------------------------------------- */ namespace { - template T IMPL_RTL_STRNAME( toInt )( const IMPL_RTL_STRCODE* pStr, - sal_Int16 nRadix ) + template T IMPL_RTL_STRNAME( toInt_WithLength )( const IMPL_RTL_STRCODE* pStr, + sal_Int16 nRadix, + sal_Int32 nStrLength ) { static_assert(std::numeric_limits::is_signed, "is signed"); assert( nRadix >= RTL_STR_MIN_RADIX && nRadix <= RTL_STR_MAX_RADIX ); + assert( nStrLength >= 0 ); bool bNeg; sal_Int16 nDigit; U n = 0; + const IMPL_RTL_STRCODE* pEnd = pStr + nStrLength; if ( (nRadix < RTL_STR_MIN_RADIX) || (nRadix > RTL_STR_MAX_RADIX) ) nRadix = 10; /* Skip whitespaces */ - while ( *pStr && rtl_ImplIsWhitespace( IMPL_RTL_USTRCODE( *pStr ) ) ) + while ( pStr != pEnd && rtl_ImplIsWhitespace( IMPL_RTL_USTRCODE( *pStr ) ) ) pStr++; if ( *pStr == '-' ) @@ -1039,7 +1042,7 @@ namespace { nMod = std::numeric_limits::max() % nRadix; } - while ( *pStr ) + while ( pStr != pEnd ) { nDigit = rtl_ImplGetDigit( IMPL_RTL_USTRCODE( *pStr ), nRadix ); if ( nDigit < 0 ) @@ -1067,7 +1070,7 @@ sal_Int32 SAL_CALL IMPL_RTL_STRNAME( toInt32 )( const IMPL_RTL_STRCODE* pStr, SAL_THROW_EXTERN_C() { assert(pStr); - return IMPL_RTL_STRNAME( toInt )(pStr, nRadix); + return IMPL_RTL_STRNAME( toInt_WithLength )(pStr, nRadix, IMPL_RTL_STRNAME( getLength )(pStr)); } sal_Int64 SAL_CALL IMPL_RTL_STRNAME( toInt64 )( const IMPL_RTL_STRCODE* pStr, @@ -1075,7 +1078,16 @@ sal_Int64 SAL_CALL IMPL_RTL_STRNAME( toInt64 )( const IMPL_RTL_STRCODE* pStr, SAL_THROW_EXTERN_C() { assert(pStr); - return IMPL_RTL_STRNAME( toInt )(pStr, nRadix); + return IMPL_RTL_STRNAME( toInt_WithLength )(pStr, nRadix, IMPL_RTL_STRNAME( getLength )(pStr)); +} + +sal_Int64 SAL_CALL IMPL_RTL_STRNAME( toInt64_WithLength )( const IMPL_RTL_STRCODE* pStr, + sal_Int16 nRadix, + sal_Int32 nStrLength) + SAL_THROW_EXTERN_C() +{ + assert(pStr); + return IMPL_RTL_STRNAME( toInt_WithLength )(pStr, nRadix, nStrLength); } /* ----------------------------------------------------------------------- */ -- cgit