formula/source/ui/dlg/FormulaHelper.cxx | 16 ++++++++-------- include/formula/formulahelper.hxx | 8 ++++---- include/sax/fastattribs.hxx | 5 ++++- 3 files changed, 16 insertions(+), 13 deletions(-)
New commits: commit 01c9e8808bdee7ee355a037fda2889150f21f6fe Author: Noel Grandin <[email protected]> AuthorDate: Wed Sep 28 10:30:43 2022 +0200 Commit: Noel Grandin <[email protected]> CommitDate: Wed Sep 28 11:28:53 2022 +0200 use more string_view in formula Change-Id: I3d9feafb0e2010f284a1700becbe9b701edc9849 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140697 Tested-by: Jenkins Reviewed-by: Noel Grandin <[email protected]> diff --git a/formula/source/ui/dlg/FormulaHelper.cxx b/formula/source/ui/dlg/FormulaHelper.cxx index 15d3b411a4a2..85799c40ecc2 100644 --- a/formula/source/ui/dlg/FormulaHelper.cxx +++ b/formula/source/ui/dlg/FormulaHelper.cxx @@ -131,7 +131,7 @@ bool FormulaHelper::GetNextFunc( const OUString& rFormula, } -void FormulaHelper::FillArgStrings( const OUString& rFormula, +void FormulaHelper::FillArgStrings( std::u16string_view rFormula, sal_Int32 nFuncPos, sal_uInt16 nArgs, ::std::vector< OUString >& _rArgs ) const @@ -150,7 +150,7 @@ void FormulaHelper::FillArgStrings( const OUString& rFormula, nEnd = GetArgStart( rFormula, nFuncPos, i+1 ); if ( nEnd != nStart ) - _rArgs.push_back(rFormula.copy( nStart, nEnd-1-nStart )); + _rArgs.push_back(OUString(rFormula.substr( nStart, nEnd-1-nStart ))); else { _rArgs.emplace_back(); @@ -161,7 +161,7 @@ void FormulaHelper::FillArgStrings( const OUString& rFormula, { nEnd = GetFunctionEnd( rFormula, nFuncPos )-1; if ( nStart < nEnd ) - _rArgs.push_back( rFormula.copy( nStart, nEnd-nStart ) ); + _rArgs.push_back( OUString(rFormula.substr( nStart, nEnd-nStart )) ); else _rArgs.emplace_back(); } @@ -174,7 +174,7 @@ void FormulaHelper::FillArgStrings( const OUString& rFormula, void FormulaHelper::GetArgStrings( ::std::vector< OUString >& _rArgs, - const OUString& rFormula, + std::u16string_view rFormula, sal_Int32 nFuncPos, sal_uInt16 nArgs ) const { @@ -299,9 +299,9 @@ sal_Int32 FormulaHelper::GetFunctionStart( const OUString& rFormula, } -sal_Int32 FormulaHelper::GetFunctionEnd( const OUString& rStr, sal_Int32 nStart ) const +sal_Int32 FormulaHelper::GetFunctionEnd( std::u16string_view rStr, sal_Int32 nStart ) const { - sal_Int32 nStrLen = rStr.getLength(); + sal_Int32 nStrLen = rStr.size(); if ( nStrLen < nStart ) return nStart; @@ -358,9 +358,9 @@ sal_Int32 FormulaHelper::GetFunctionEnd( const OUString& rStr, sal_Int32 nStart } -sal_Int32 FormulaHelper::GetArgStart( const OUString& rStr, sal_Int32 nStart, sal_uInt16 nArg ) const +sal_Int32 FormulaHelper::GetArgStart( std::u16string_view rStr, sal_Int32 nStart, sal_uInt16 nArg ) const { - sal_Int32 nStrLen = rStr.getLength(); + sal_Int32 nStrLen = rStr.size(); if ( nStrLen < nStart ) return nStart; diff --git a/include/formula/formulahelper.hxx b/include/formula/formulahelper.hxx index 02f757dc3726..f57a276fb178 100644 --- a/include/formula/formulahelper.hxx +++ b/include/formula/formulahelper.hxx @@ -62,17 +62,17 @@ namespace formula sal_Int32 GetFunctionStart( const OUString& rFormula, sal_Int32 nStart, bool bBack, OUString* pFuncName = nullptr ) const; - sal_Int32 GetFunctionEnd ( const OUString& rFormula, sal_Int32 nStart ) const; + sal_Int32 GetFunctionEnd ( std::u16string_view rFormula, sal_Int32 nStart ) const; - sal_Int32 GetArgStart ( const OUString& rFormula, sal_Int32 nStart, + sal_Int32 GetArgStart ( std::u16string_view rFormula, sal_Int32 nStart, sal_uInt16 nArg ) const; void GetArgStrings ( ::std::vector< OUString >& _rArgs, - const OUString& rFormula, + std::u16string_view rFormula, sal_Int32 nFuncPos, sal_uInt16 nArgs ) const; - void FillArgStrings ( const OUString& rFormula, + void FillArgStrings ( std::u16string_view rFormula, sal_Int32 nFuncPos, sal_uInt16 nArgs, ::std::vector< OUString >& _rArgs ) const; commit a1d6ec66ce4b8dd84f0962f9b749b831cbb05baf Author: Noel Grandin <[email protected]> AuthorDate: Wed Sep 28 09:24:13 2022 +0200 Commit: Noel Grandin <[email protected]> CommitDate: Wed Sep 28 11:28:39 2022 +0200 elide strlen cost in FastAttributeIter::toDouble by inlining the underlying code to rtl_str_toDouble Change-Id: If379bf40472455be93ca4da6ece25a126bed0b73 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140691 Tested-by: Jenkins Reviewed-by: Noel Grandin <[email protected]> diff --git a/include/sax/fastattribs.hxx b/include/sax/fastattribs.hxx index ef7e97884735..22512bd5a929 100644 --- a/include/sax/fastattribs.hxx +++ b/include/sax/fastattribs.hxx @@ -25,6 +25,7 @@ #include <com/sun/star/util/XCloneable.hpp> #include <cppuhelper/implbase.hxx> +#include <rtl/math.h> #include <sax/saxdllapi.h> #include <string_view> @@ -172,7 +173,9 @@ public: double toDouble() const { assert(mnIdx < mrList.maAttributeTokens.size()); - return rtl_str_toDouble(mrList.getFastAttributeValue(mnIdx)); + const char* pStr = mrList.getFastAttributeValue(mnIdx); + sal_Int32 nLen = mrList.AttributeValueLength(mnIdx); + return rtl_math_stringToDouble(pStr, pStr + nLen, '.', 0, nullptr, nullptr); } bool toBoolean() const {
