summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2015-06-15 16:36:36 +0200
committerNoel Grandin <noel@peralex.com>2015-06-19 09:55:07 +0200
commite0f3e7c007e9eeced888b491ec2698acba4bc588 (patch)
treebb53c606375f22d63df0ca860e726d27e83fb1c3
parent0c5d286cbe299be356797447cb2b6747c68a015e (diff)
tdf#42374 some small optimisations for opening this PDF file
makes it about 10% faster Change-Id: I145faed5aa7c312372f08cc651df5afcf10c70ab
-rw-r--r--sdext/source/pdfimport/tree/drawtreevisiting.cxx43
-rw-r--r--sdext/source/pdfimport/tree/writertreevisiting.cxx33
-rw-r--r--svl/source/notify/lstner.cxx5
-rw-r--r--xmloff/source/draw/shapeimport.cxx28
4 files changed, 49 insertions, 60 deletions
diff --git a/sdext/source/pdfimport/tree/drawtreevisiting.cxx b/sdext/source/pdfimport/tree/drawtreevisiting.cxx
index e722dc3cd680..832d35569630 100644
--- a/sdext/source/pdfimport/tree/drawtreevisiting.cxx
+++ b/sdext/source/pdfimport/tree/drawtreevisiting.cxx
@@ -355,8 +355,8 @@ void DrawXmlEmitter::visit( PageElement& elem, const std::list< Element* >::cons
if( m_rEmitContext.xStatusIndicator.is() )
m_rEmitContext.xStatusIndicator->setValue( elem.PageNumber );
- std::list< Element* >::iterator this_it = elem.Children.begin();
- while( this_it !=elem.Children.end() && *this_it != &elem )
+ std::list< Element* >::iterator this_it = elem.Children.begin();
+ while( this_it != elem.Children.end() && *this_it != &elem )
{
(*this_it)->visitedBy( *this, this_it );
++this_it;
@@ -371,8 +371,8 @@ void DrawXmlEmitter::visit( DocumentElement& elem, const std::list< Element* >::
m_rEmitContext.rEmitter.beginTag( m_bWriteDrawDocument ? "office:drawing" : "office:presentation",
PropertyMap() );
- std::list< Element* >::iterator this_it = elem.Children.begin();
- while( this_it !=elem.Children.end() && *this_it != &elem )
+ std::list< Element* >::iterator this_it = elem.Children.begin();
+ while( this_it != elem.Children.end() && *this_it != &elem )
{
(*this_it)->visitedBy( *this, this_it );
++this_it;
@@ -401,29 +401,28 @@ void DrawXmlOptimizer::visit( ImageElement&, const std::list< Element* >::const_
{
}
-void DrawXmlOptimizer::visit( PolyPolyElement& elem, const std::list< Element* >::const_iterator& )
+void DrawXmlOptimizer::visit( PolyPolyElement& elem, const std::list< Element* >::const_iterator& elemIt )
{
/* note: optimize two consecutive PolyPolyElements that
* have the same path but one of which is a stroke while
* the other is a fill
*/
- if( elem.Parent )
- {
- // find following PolyPolyElement in parent's children list
- std::list< Element* >::iterator this_it = elem.Parent->Children.begin();
- while( this_it != elem.Parent->Children.end() && *this_it != &elem )
- ++this_it;
+ if( !elem.Parent )
+ return;
- if( this_it != elem.Parent->Children.end() )
- {
- std::list< Element* >::iterator next_it = this_it;
- if( ++next_it != elem.Parent->Children.end() )
- {
- PolyPolyElement* pNext = dynamic_cast<PolyPolyElement*>(*next_it);
+ // find following PolyPolyElement in parent's children list
+ if( elemIt == elem.Parent->Children.end() )
+ return;
+ std::list< Element* >::const_iterator next_it = elemIt;
+ ++next_it;
+ if( next_it == elem.Parent->Children.end() )
+ return;
+
+ PolyPolyElement* pNext = dynamic_cast<PolyPolyElement*>(*next_it);
+ // TODO(F2): this comparison fails for OOo-generated polygons with beziers.
+ if( !pNext || pNext->PolyPoly != elem.PolyPoly )
+ return;
- // TODO(F2): this comparison fails for OOo-generated polygons with beziers.
- if( pNext && pNext->PolyPoly == elem.PolyPoly )
- {
const GraphicsContext& rNextGC =
m_rProcessor.getGraphicsContext( pNext->GCId );
const GraphicsContext& rThisGC =
@@ -455,10 +454,6 @@ void DrawXmlOptimizer::visit( PolyPolyElement& elem, const std::list< Element* >
elem.Parent->Children.erase( next_it );
delete pNext;
}
- }
- }
- }
- }
}
void DrawXmlOptimizer::visit( ParagraphElement& elem, const std::list< Element* >::const_iterator& )
diff --git a/sdext/source/pdfimport/tree/writertreevisiting.cxx b/sdext/source/pdfimport/tree/writertreevisiting.cxx
index d880191700db..0844c6ee58b9 100644
--- a/sdext/source/pdfimport/tree/writertreevisiting.cxx
+++ b/sdext/source/pdfimport/tree/writertreevisiting.cxx
@@ -358,27 +358,26 @@ void WriterXmlOptimizer::visit( ImageElement&, const std::list< Element* >::cons
{
}
-void WriterXmlOptimizer::visit( PolyPolyElement& elem, const std::list< Element* >::const_iterator& )
+void WriterXmlOptimizer::visit( PolyPolyElement& elem, const std::list< Element* >::const_iterator& elemIt )
{
/* note: optimize two consecutive PolyPolyElements that
* have the same path but one of which is a stroke while
* the other is a fill
*/
- if( elem.Parent )
- {
- // find following PolyPolyElement in parent's children list
- std::list< Element* >::iterator this_it = elem.Parent->Children.begin();
- while( this_it != elem.Parent->Children.end() && *this_it != &elem )
- ++this_it;
+ if( !elem.Parent )
+ return;
+ // find following PolyPolyElement in parent's children list
+ if( elemIt == elem.Parent->Children.end() )
+ return;
+ std::list< Element* >::const_iterator next_it = elemIt;
+ ++next_it;
+ if( next_it == elem.Parent->Children.end() )
+ return;
+
+ PolyPolyElement* pNext = dynamic_cast<PolyPolyElement*>(*next_it);
+ if( !pNext || pNext->PolyPoly != elem.PolyPoly )
+ return;
- if( this_it != elem.Parent->Children.end() )
- {
- std::list< Element* >::iterator next_it = this_it;
- if( ++next_it != elem.Parent->Children.end() )
- {
- PolyPolyElement* pNext = dynamic_cast<PolyPolyElement*>(*next_it);
- if( pNext && pNext->PolyPoly == elem.PolyPoly )
- {
const GraphicsContext& rNextGC =
m_rProcessor.getGraphicsContext( pNext->GCId );
const GraphicsContext& rThisGC =
@@ -406,10 +405,6 @@ void WriterXmlOptimizer::visit( PolyPolyElement& elem, const std::list< Element*
elem.Parent->Children.erase( next_it );
delete pNext;
}
- }
- }
- }
- }
}
void WriterXmlOptimizer::visit( ParagraphElement& elem, const std::list< Element* >::const_iterator& rParentIt)
diff --git a/svl/source/notify/lstner.cxx b/svl/source/notify/lstner.cxx
index b7b338767a5e..ee0809cd0db7 100644
--- a/svl/source/notify/lstner.cxx
+++ b/svl/source/notify/lstner.cxx
@@ -90,15 +90,16 @@ void SfxListener::StartListening( SfxBroadcaster& rBroadcaster, bool bPreventDup
void SfxListener::EndListening( SfxBroadcaster& rBroadcaster, bool bAllDups )
{
+ SfxBroadcasterArr_Impl::iterator beginIt = mpImpl->maBCs.begin();
do
{
- SfxBroadcasterArr_Impl::iterator it = std::find( mpImpl->maBCs.begin(), mpImpl->maBCs.end(), &rBroadcaster );
+ SfxBroadcasterArr_Impl::iterator it = std::find( beginIt, mpImpl->maBCs.end(), &rBroadcaster );
if ( it == mpImpl->maBCs.end() )
{
break;
}
rBroadcaster.RemoveListener(*this);
- mpImpl->maBCs.erase( it );
+ beginIt = mpImpl->maBCs.erase( it );
}
while ( bAllDups );
}
diff --git a/xmloff/source/draw/shapeimport.cxx b/xmloff/source/draw/shapeimport.cxx
index d86ee5094c3a..d7581a235716 100644
--- a/xmloff/source/draw/shapeimport.cxx
+++ b/xmloff/source/draw/shapeimport.cxx
@@ -775,8 +775,8 @@ class ShapeSortContext
{
public:
uno::Reference< drawing::XShapes > mxShapes;
- list<ZOrderHint> maZOrderList;
- list<ZOrderHint> maUnsortedList;
+ vector<ZOrderHint> maZOrderList;
+ vector<ZOrderHint> maUnsortedList;
sal_Int32 mnCurrentZ;
ShapeSortContext* mpParentContext;
@@ -804,8 +804,8 @@ void ShapeSortContext::moveShape( sal_Int32 nSourcePos, sal_Int32 nDestPos )
aAny <<= nDestPos;
xPropSet->setPropertyValue( msZOrder, aAny );
- list<ZOrderHint>::iterator aIter = maZOrderList.begin();
- list<ZOrderHint>::iterator aEnd = maZOrderList.end();
+ vector<ZOrderHint>::iterator aIter = maZOrderList.begin();
+ vector<ZOrderHint>::iterator aEnd = maZOrderList.end();
while( aIter != aEnd )
{
@@ -845,8 +845,8 @@ void XMLShapeImportHelper::popGroupAndSort()
try
{
- list<ZOrderHint>& rZList = mpImpl->mpSortContext->maZOrderList;
- list<ZOrderHint>& rUnsortedList = mpImpl->mpSortContext->maUnsortedList;
+ vector<ZOrderHint>& rZList = mpImpl->mpSortContext->maZOrderList;
+ vector<ZOrderHint>& rUnsortedList = mpImpl->mpSortContext->maUnsortedList;
// sort shapes
if( !rZList.empty() )
@@ -867,7 +867,7 @@ void XMLShapeImportHelper::popGroupAndSort()
if( nCount > 0 )
{
// first update offsets of added shapes
- list<ZOrderHint>::iterator aIter( rZList.begin() );
+ vector<ZOrderHint>::iterator aIter( rZList.begin() );
while( aIter != rZList.end() )
(*aIter++).nIs += nCount;
@@ -891,27 +891,25 @@ void XMLShapeImportHelper::popGroupAndSort()
}
// sort z ordered shapes
- rZList.sort();
+ std::sort(rZList.begin(), rZList.end());
// this is the current index, all shapes before that
// index are finished
sal_Int32 nIndex = 0;
while( !rZList.empty() )
{
- list<ZOrderHint>::iterator aIter( rZList.begin() );
-
- while( nIndex < (*aIter).nShould && !rUnsortedList.empty() )
+ while( nIndex < (*rZList.begin()).nShould && !rUnsortedList.empty() )
{
ZOrderHint aGapHint( *rUnsortedList.begin() );
- rUnsortedList.pop_front();
+ rUnsortedList.erase(rUnsortedList.begin());
mpImpl->mpSortContext->moveShape( aGapHint.nIs, nIndex++ );
}
- if( (*aIter).nIs != nIndex )
- mpImpl->mpSortContext->moveShape( (*aIter).nIs, nIndex );
+ if( (*rZList.begin()).nIs != nIndex )
+ mpImpl->mpSortContext->moveShape( (*rZList.begin()).nIs, nIndex );
- rZList.pop_front();
+ rZList.erase(rZList.begin());
nIndex++;
}
}