diff options
author | Markus Mohrhard <markus.mohrhard@collabora.co.uk> | 2015-10-03 10:01:01 +0200 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@collabora.co.uk> | 2015-10-03 10:01:51 +0200 |
commit | bf3dd18cf86fd45882b813d08c3df5d7cd097246 (patch) | |
tree | f476bf58672170dafa19244271281743df241175 /formula | |
parent | move ConvertStringToValue() implementation from ScInterpreter to ScGlobal (diff) | |
download | core-bf3dd18cf86fd45882b813d08c3df5d7cd097246.tar.gz core-bf3dd18cf86fd45882b813d08c3df5d7cd097246.zip |
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
Diffstat (limited to 'formula')
-rw-r--r-- | formula/source/core/api/token.cxx | 38 |
1 files changed, 18 insertions, 20 deletions
diff --git a/formula/source/core/api/token.cxx b/formula/source/core/api/token.cxx index ac95b8dd6dec..b0e84f314c75 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; } |