[Libreoffice-commits] core.git: sdext/source svl/source xmloff/source
Noel Grandin
noel at peralex.com
Fri Jun 19 01:07:22 PDT 2015
sdext/source/pdfimport/tree/drawtreevisiting.cxx | 43 +++++++++------------
sdext/source/pdfimport/tree/writertreevisiting.cxx | 33 ++++++----------
svl/source/notify/lstner.cxx | 5 +-
xmloff/source/draw/shapeimport.cxx | 28 ++++++-------
4 files changed, 49 insertions(+), 60 deletions(-)
New commits:
commit e0f3e7c007e9eeced888b491ec2698acba4bc588
Author: Noel Grandin <noel at peralex.com>
Date: Mon Jun 15 16:36:36 2015 +0200
tdf#42374 some small optimisations for opening this PDF file
makes it about 10% faster
Change-Id: I145faed5aa7c312372f08cc651df5afcf10c70ab
diff --git a/sdext/source/pdfimport/tree/drawtreevisiting.cxx b/sdext/source/pdfimport/tree/drawtreevisiting.cxx
index e722dc3..832d355 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 d880191..0844c6e 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 b7b3387..ee0809c 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 d86ee50..d7581a2 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++;
}
}
More information about the Libreoffice-commits
mailing list