sc/source/core/data/formulacell.cxx | 46 +++++++++++++++++++++++++++++++++--- 1 file changed, 43 insertions(+), 3 deletions(-)
New commits: commit 9d9c0b5194839b3cdf814b77f1cc0584b4b43ef5 Author: Michael Meeks <michael.me...@collabora.com> Date: Sat May 24 21:43:16 2014 +0100 ODS load perf: remove left-over / debugging getenv. Change-Id: I08bae50685ce52b8329b11b8ca3d083648dfc6fc diff --git a/sc/source/core/data/formulacell.cxx b/sc/source/core/data/formulacell.cxx index 69debaf..1e63308 100644 --- a/sc/source/core/data/formulacell.cxx +++ b/sc/source/core/data/formulacell.cxx @@ -1187,9 +1187,7 @@ void ScFormulaCell::CompileXML( sc::CompileFormulaContext& rCxt, ScProgress& rPr bool bSkipCompile = false; - static bool bNewPath = getenv ("FASTFORMULA"); - - if ( bNewPath && !mxGroup && aFormulaNmsp.isEmpty() ) // optimization + if ( !mxGroup && aFormulaNmsp.isEmpty() ) // optimization { ScAddress aPreviousCell( aPos ); aPreviousCell.IncRow( -1 ); commit 7a1f047cf82ae5b8eff3dd1ed16dec93c5f36c52 Author: Michael Meeks <michael.me...@collabora.com> Date: Fri May 23 21:51:14 2014 +0100 ODS load perf: accelerate CompileXML for formula by stringify and compare. For long columns of repeated formula, it is far faster to convert a formula to a string and compare to see if the next cell in a column matches, than it is to parse the formula string itself (sad but true). This saves 29s of 131s of load time for my (admittedly large) ODS file. Change-Id: I48b613eb7131d6eb3902695aa30a1aa1a9ea5f6a diff --git a/sc/source/core/data/formulacell.cxx b/sc/source/core/data/formulacell.cxx index ec07bde..69debaf 100644 --- a/sc/source/core/data/formulacell.cxx +++ b/sc/source/core/data/formulacell.cxx @@ -1184,9 +1184,51 @@ void ScFormulaCell::CompileXML( sc::CompileFormulaContext& rCxt, ScProgress& rPr // pCode may not deleted for queries, but must be empty if ( pCode ) pCode->Clear(); - ScTokenArray* pCodeOld = pCode; - pCode = aComp.CompileString( aFormula, aFormulaNmsp ); - delete pCodeOld; + + bool bSkipCompile = false; + + static bool bNewPath = getenv ("FASTFORMULA"); + + if ( bNewPath && !mxGroup && aFormulaNmsp.isEmpty() ) // optimization + { + ScAddress aPreviousCell( aPos ); + aPreviousCell.IncRow( -1 ); + ScFormulaCell *pPreviousCell = pDocument->GetFormulaCell( aPreviousCell ); + if( pPreviousCell ) + { + // Now try to convert to a string quickly ... + ScCompiler aBackComp( rCxt, aPos, *(pPreviousCell->pCode) ); + OUStringBuffer aShouldBeBuf; + aBackComp.CreateStringFromTokenArray( aShouldBeBuf ); + + assert( aFormula[0] == '=' ); + OUString aShouldBe = aShouldBeBuf.makeStringAndClear(); + if( aFormula.getLength() == aShouldBe.getLength() + 1 && + aFormula.match( aShouldBe, 1 ) ) // initial '=' + { + // Put them in the same formula group. + ScFormulaCellGroupRef xGroup = pPreviousCell->GetCellGroup(); + if (!xGroup) // Last cell is not grouped yet. Start a new group. + xGroup = pPreviousCell->CreateCellGroup(1, false); + ++xGroup->mnLength; + SetCellGroup( xGroup ); + + bSkipCompile = true; + + SAL_INFO( "sc", "merged '" << aFormula << "' == " + "'" << aShouldBe << "'" << + " extend group to " << xGroup->mnLength ); + } + } + } + + if (!bSkipCompile) + { + ScTokenArray* pCodeOld = pCode; + pCode = aComp.CompileString( aFormula, aFormulaNmsp ); + delete pCodeOld; + } + if( !pCode->GetCodeError() ) { if ( !pCode->GetLen() ) _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits