About simplifying sortElements in pdfiprocessor (sdext)

Julien Nabet serval2412 at yahoo.fr
Thu Feb 1 17:16:12 UTC 2018


I noticed this part in PDFIProcessor::sortElements from 

     700     // HACK: the stable sort member on std::list that takes a
     701     // strict weak ordering requires member templates - which we
     702     // do not have on all compilers. so we need to use 
     703     // here - which does need random access iterators which the
     704     // list iterators are not.
     705     // so we need to copy the Element* to an array, stable sort 
that and
     706     // copy them back.
     707     std::vector<Element*> aChildren;
     708     while( ! pEle->Children.empty() )
     709     {
     710         aChildren.push_back( pEle->Children.front() );
     711         pEle->Children.pop_front();
     712     }
     713     std::stable_sort( aChildren.begin(), aChildren.end(), 
lr_tb_sort );
     714     for (auto const& child : aChildren)
     715         pEle->Children.push_back(child);


1) Using directly sort method of std::list and get rid of intermediary 

The comment has been put in 2008 (see 

Is the comment still right for some compilers or may we use the sort 
method of std::list now ?

2) Useless recursion?

This function takes bDeep as parameter and can call itself if bDeep is 
equal to true.

However, Opengrok shows that:

- default value for bDeep is false

- this function is never called with the value true



More information about the LibreOffice mailing list