formula/source/core/api/token.cxx | 38 ++++++++++++++++++-------------------- include/formula/tokenarray.hxx | 6 +++--- 2 files changed, 21 insertions(+), 23 deletions(-)
New commits: commit bf3dd18cf86fd45882b813d08c3df5d7cd097246 Author: Markus Mohrhard <markus.mohrh...@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 diff --git a/formula/source/core/api/token.cxx b/formula/source/core/api/token.cxx index ac95b8d..b0e84f3 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 7a745b6..0f303ac 100644 --- a/include/formula/tokenarray.hxx +++ b/include/formula/tokenarray.hxx @@ -330,7 +330,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& ); @@ -339,8 +339,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 => _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits