[Libreoffice-commits] core.git: Branch 'feature/fastsax' - include/vcl sc/inc sc/source
Michael Meeks
michael.meeks at collabora.com
Fri May 23 13:51:36 PDT 2014
include/vcl/debugevent.hxx | 6 +++-
sc/inc/formulacell.hxx | 2 -
sc/source/core/data/formulacell.cxx | 49 +++++++++++++++++++++++++++++++++---
3 files changed, 51 insertions(+), 6 deletions(-)
New commits:
commit 5fcd3eb1ca7408bd0fb986b32ab642f5a6533b81
Author: Michael Meeks <michael.meeks at collabora.com>
Date: Fri May 23 21:51:14 2014 +0100
First cut at accelerated formula parsing - saves 29s of 131s for my file.
Change-Id: I48b613eb7131d6eb3902695aa30a1aa1a9ea5f6a
diff --git a/include/vcl/debugevent.hxx b/include/vcl/debugevent.hxx
index 2700324..c61f93f 100644
--- a/include/vcl/debugevent.hxx
+++ b/include/vcl/debugevent.hxx
@@ -10,6 +10,8 @@
#ifndef INCLUDED_VCL_DEBUGEVENT_HXX
#define INCLUDED_VCL_DEBUGEVENT_HXX
+#if OSL_DEBUG_LEVEL > 0
+
#include <vcl/dllapi.h>
#include <vcl/timer.hxx>
#include <sal/types.h>
@@ -25,12 +27,14 @@ class VCL_DLLPUBLIC DebugEventInjector : Timer {
void InjectMouseEvent();
void InjectEvent();
void InjectKeyNavEdit();
- virtual void Timeout();
+ virtual void Timeout() SAL_OVERRIDE;
public:
static DebugEventInjector *getCreate();
};
+#endif // OSL_DEBUG_LEVEL > 0
+
#endif // INCLUDED_VCL_DEBUGEVENT_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/inc/formulacell.hxx b/sc/inc/formulacell.hxx
index 11c5cb1..3301d1e 100644
--- a/sc/inc/formulacell.hxx
+++ b/sc/inc/formulacell.hxx
@@ -375,7 +375,7 @@ public:
* Turn a non-grouped cell into the top of a grouped cell.
*/
ScFormulaCellGroupRef CreateCellGroup( SCROW nLen, bool bInvariant );
- ScFormulaCellGroupRef GetCellGroup();
+ ScFormulaCellGroupRef GetCellGroup() const;
void SetCellGroup( const ScFormulaCellGroupRef &xRef );
CompareState CompareByTokenArray( ScFormulaCell& rOther ) const;
diff --git a/sc/source/core/data/formulacell.cxx b/sc/source/core/data/formulacell.cxx
index ec07bde..1e66722 100644
--- a/sc/source/core/data/formulacell.cxx
+++ b/sc/source/core/data/formulacell.cxx
@@ -1184,9 +1184,50 @@ 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 aShouldBe;
+ aBackComp.CreateStringFromTokenArray( aShouldBe );
+
+ fprintf (stderr, "compile '%s' ==? '%s'\n",
+ OUStringToOString( aFormula, RTL_TEXTENCODING_UTF8 ).getStr(),
+ OUStringToOString( aShouldBe.toString(), RTL_TEXTENCODING_UTF8 ).getStr());
+ assert( aFormula[0] == '=' );
+ if( aFormula.match(aShouldBe.makeStringAndClear(), 1) )
+ {
+ // 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;
+
+ fprintf (stderr, "\twhoot ! a match - extended to %d\n",
+ (int)xGroup->mnLength);
+ }
+ }
+ }
+
+ if (!bSkipCompile)
+ {
+ ScTokenArray* pCodeOld = pCode;
+ pCode = aComp.CompileString( aFormula, aFormulaNmsp );
+ delete pCodeOld;
+ }
+
if( !pCode->GetCodeError() )
{
if ( !pCode->GetLen() )
@@ -3494,7 +3535,7 @@ ScFormulaCellGroupRef ScFormulaCell::CreateCellGroup( SCROW nLen, bool bInvarian
return mxGroup;
}
-ScFormulaCellGroupRef ScFormulaCell::GetCellGroup()
+ScFormulaCellGroupRef ScFormulaCell::GetCellGroup() const
{
return mxGroup;
}
More information about the Libreoffice-commits
mailing list