diff options
author | Eike Rathke <erack@redhat.com> | 2016-09-20 21:39:10 +0200 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2016-09-20 21:50:52 +0200 |
commit | 73c7e0921d752df53004ed55735f3e8888cc592f (patch) | |
tree | 6b67797cc294bda360e3f2508b6a10527e48471b | |
parent | 3b658417dc563e48906ba246ec2bfeaaefb5603b (diff) |
sc-perf: tdf#79023 for ODFF do not call SvNumberFormatter to determine numeric
Speedup of this particular function and callees by factor 33 ...
1000 calls for =12345.6789 and =123.456 alternating:
Before:
Ir Irpc Callee
9859177 9859 ScCompiler::IsValue
6246858 6246 SvNumberFormatter::IsNumberFormat
3496261 3496 SvNumberFormatter::GetStandardIndex
After:
298000 298 ScCompiler::IsValue
248000 248 rtl_math_uStringToDouble
Change-Id: I36eac8c5fe1b1cbf34dfb480c9e7ca6607769364
-rw-r--r-- | sc/source/core/tool/compiler.cxx | 48 |
1 files changed, 44 insertions, 4 deletions
diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx index 921ee9793b8d..e620032bf8ee 100644 --- a/sc/source/core/tool/compiler.cxx +++ b/sc/source/core/tool/compiler.cxx @@ -2885,8 +2885,51 @@ bool ScCompiler::IsOpCode2( const OUString& rName ) return bFound; } +static bool lcl_ParenthesisFollows( const sal_Unicode* p ) +{ + while (*p == ' ') + p++; + return *p == '('; +} + bool ScCompiler::IsValue( const OUString& rSym ) { + if (FormulaGrammar::isODFF( GetGrammar())) + { + // Speedup things for ODFF, only well-formed numbers, not locale + // dependent nor user input. + rtl_math_ConversionStatus eStatus; + sal_Int32 nParseEnd; + double fVal = rtl::math::stringToDouble( rSym, '.', 0, &eStatus, &nParseEnd); + if (nParseEnd != rSym.getLength()) + { + // Not (only) a number. + + if (nParseEnd > 0) + return false; // partially a number => no such thing + + if (lcl_ParenthesisFollows( aFormula.getStr() + nSrcPos)) + return false; // some function name, not a constant + + // Could be TRUE or FALSE constant. + if (rSym.equalsIgnoreAsciiCase("TRUE")) + { + maRawToken.SetDouble( 1.0 ); + return true; + } + if (rSym.equalsIgnoreAsciiCase("FALSE")) + { + maRawToken.SetDouble( 0.0 ); + return true; + } + return false; + } + if (eStatus == rtl_math_ConversionStatus_OutOfRange) + SetError( errIllegalArgument ); + maRawToken.SetDouble( fVal ); + return true; + } + double fVal; sal_uInt32 nIndex = mxSymbols->isEnglish() ? mpFormatter->GetStandardIndex(LANGUAGE_ENGLISH_US) : 0; @@ -2905,10 +2948,7 @@ bool ScCompiler::IsValue( const OUString& rSym ) if (nType == css::util::NumberFormat::LOGICAL) { - const sal_Unicode* p = aFormula.getStr() + nSrcPos; - while( *p == ' ' ) - p++; - if (*p == '(') + if (lcl_ParenthesisFollows( aFormula.getStr() + nSrcPos)) return false; // Boolean function instead. } |