[Libreoffice-commits] core.git: Branch 'feature/fixes10' - formula/source include/formula
Markus Mohrhard
markus.mohrhard at collabora.co.uk
Mon Oct 5 02:10:16 PDT 2015
formula/source/core/api/token.cxx | 38 ++++++++++++++++++--------------------
include/formula/tokenarray.hxx | 6 +++---
2 files changed, 21 insertions(+), 23 deletions(-)
New commits:
commit e2b1355ccbec3c0b8d8ab1b6c427ed5cc1cf68a8
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date: Sat Oct 3 10:01:01 2015 +0200
no need to allocate that vector on the heap
This seems to give about 10% performance improvements in some calc cell
calculations.
Change-Id: Ibd91558b3c107e4c8e1401345c9332f97645453e
(cherry picked from commit bf3dd18cf86fd45882b813d08c3df5d7cd097246)
diff --git a/formula/source/core/api/token.cxx b/formula/source/core/api/token.cxx
index 9f16f4c..94903e0 100644
--- a/formula/source/core/api/token.cxx
+++ b/formula/source/core/api/token.cxx
@@ -1533,39 +1533,37 @@ FormulaTokenIterator::Item::Item(const FormulaTokenArray* pArray, short pc, shor
FormulaTokenIterator::FormulaTokenIterator( const FormulaTokenArray& rArr )
{
- maStack = new std::vector<FormulaTokenIterator::Item> ();
Push( &rArr );
}
FormulaTokenIterator::~FormulaTokenIterator()
{
- delete maStack;
}
void FormulaTokenIterator::Push( const FormulaTokenArray* pArr )
{
FormulaTokenIterator::Item item(pArr, -1, SHRT_MAX);
- maStack->push_back(item);
+ maStack.push_back(item);
}
void FormulaTokenIterator::Pop()
{
- maStack->pop_back();
+ maStack.pop_back();
}
void FormulaTokenIterator::Reset()
{
- while( maStack->size() > 1 )
- maStack->pop_back();
+ while( maStack.size() > 1 )
+ maStack.pop_back();
- maStack->back().nPC = -1;
+ maStack.back().nPC = -1;
}
const FormulaToken* FormulaTokenIterator::Next()
{
- const FormulaToken* t = GetNonEndOfPathToken( ++maStack->back().nPC );
- if( !t && maStack->size() > 1 )
+ const FormulaToken* t = GetNonEndOfPathToken( ++maStack.back().nPC );
+ if( !t && maStack.size() > 1 )
{
Pop();
t = Next();
@@ -1576,18 +1574,18 @@ const FormulaToken* FormulaTokenIterator::Next()
const FormulaToken* FormulaTokenIterator::PeekNextOperator()
{
const FormulaToken* t = NULL;
- short nIdx = maStack->back().nPC;
+ short nIdx = maStack.back().nPC;
while (!t && ((t = GetNonEndOfPathToken( ++nIdx)) != NULL))
{
if (t->GetOpCode() == ocPush)
t = NULL; // ignore operands
}
- if (!t && maStack->size() > 1)
+ if (!t && maStack.size() > 1)
{
- FormulaTokenIterator::Item pHere = maStack->back();
- maStack->pop_back();
+ FormulaTokenIterator::Item pHere = maStack.back();
+ maStack.pop_back();
t = PeekNextOperator();
- maStack->push_back(pHere);
+ maStack.push_back(pHere);
}
return t;
}
@@ -1596,18 +1594,18 @@ const FormulaToken* FormulaTokenIterator::PeekNextOperator()
void FormulaTokenIterator::Jump( short nStart, short nNext, short nStop )
{
- maStack->back().nPC = nNext;
+ maStack.back().nPC = nNext;
if( nStart != nNext )
{
- Push( maStack->back().pArr );
- maStack->back().nPC = nStart;
- maStack->back().nStop = nStop;
+ Push( maStack.back().pArr );
+ maStack.back().nPC = nStart;
+ maStack.back().nStop = nStop;
}
}
const FormulaToken* FormulaTokenIterator::GetNonEndOfPathToken( short nIdx ) const
{
- FormulaTokenIterator::Item cur = maStack->back();
+ FormulaTokenIterator::Item cur = maStack.back();
if (nIdx < cur.pArr->nRPN && nIdx < cur.nStop)
{
@@ -1620,7 +1618,7 @@ const FormulaToken* FormulaTokenIterator::GetNonEndOfPathToken( short nIdx ) con
bool FormulaTokenIterator::IsEndOfPath() const
{
- return GetNonEndOfPathToken( maStack->back().nPC + 1) == NULL;
+ return GetNonEndOfPathToken( maStack.back().nPC + 1) == NULL;
}
diff --git a/include/formula/tokenarray.hxx b/include/formula/tokenarray.hxx
index 58bb092..b3b6b80 100644
--- a/include/formula/tokenarray.hxx
+++ b/include/formula/tokenarray.hxx
@@ -335,7 +335,7 @@ class FORMULA_DLLPUBLIC FormulaTokenIterator
Item(const FormulaTokenArray* arr, short pc, short stop);
};
- std::vector<Item> *maStack;
+ std::vector<Item> maStack;
public:
FormulaTokenIterator( const FormulaTokenArray& );
@@ -344,8 +344,8 @@ public:
const FormulaToken* Next();
const FormulaToken* PeekNextOperator();
bool IsEndOfPath() const; /// if a jump or subroutine path is done
- bool HasStacked() const { return maStack->size() > 1; }
- short GetPC() const { return maStack->back().nPC; }
+ bool HasStacked() const { return maStack.size() > 1; }
+ short GetPC() const { return maStack.back().nPC; }
/** Jump or subroutine call.
Program counter values will be incremented before code is executed =>
More information about the Libreoffice-commits
mailing list