On Thu, Feb 09, 2006 at 11:58:26AM +0100, Abdelrazak Younes wrote: > Anyway, please find attached the patch. Everything but CutAndPaste > (which crashes lyx) seems to work OK. But I didn't do extensive > testing... sorry about that. If this is interesting to you, I'll try to > find some time this week-end to refine the approach.
It is certainly intersting, and I think it is consensus that something like this needs to be done. > Index: ParagraphList_fwd.h > =================================================================== > RCS file: /var/cvs/lyx/lyx-devel/src/ParagraphList_fwd.h,v > retrieving revision 1.4 > diff -u -r1.4 ParagraphList_fwd.h > --- ParagraphList_fwd.h 16 Nov 2004 20:41:37 -0000 1.4 > +++ ParagraphList_fwd.h 8 Feb 2006 22:12:43 -0000 > @@ -14,13 +14,90 @@ > > #include "paragraph.h" > > +#include <list> > #include <vector> > > -class ParagraphList : public std::vector<Paragraph> > +using namespace std; Please no 'using' in headers. > --- output_docbook.C 20 May 2005 09:13:42 -0000 1.30 > +++ output_docbook.C 8 Feb 2006 19:02:37 -0000 > @@ -47,7 +47,7 @@ > ParagraphList::const_iterator searchParagraph(ParagraphList::const_iterator > const & par, > ParagraphList::const_iterator > const & pend) > { > - ParagraphList::const_iterator p = par + 1; > + ParagraphList::const_iterator p = par; p++; Or 'p = boost::next(par)' ... > using std::ostringstream; > > +// Reserve Memory for 100000 iterators > +// which would represent 1000000 paragraph > +// I guess this is enough? > +const size_t VECTOR_RESERVE = 1000000; Overkill. 10000 is more than anybody uses. Note also that e.h. each table cell has a ParagraphList, so for 50 x 50 table you'd reserve 2.5 * 10^9 items. No good. Use 100 or so for VECTOR_RESERVE _at max_. In fact, I do think we should not reserve anything. > +Paragraph& ParagraphList::get(size_t pos) > +{ > + BOOST_ASSERT(pos < PliVector_.size()); > + return *PliVector_[pos]; > +} Could that be called 'at(..)'? > + > +size_t ParagraphList::size() const > +{ > + return PliVector_.size(); > +} > + > +ParagraphList::const_iterator ParagraphList::begin() const > +{ > + return ParList_.begin(); > +} I'd guess most of these functions should be inline in the header. > +{ > + bool result=true; > + for (size_t i=start; i<end; ++i) bool result = true; for (size_t i = start; i < end; ++i) People are picky here ;-} Andre'