On Wed, Jan 04, 2006 at 11:53:45AM +0100, Abdel wrote: > From what I see it uses size() and operator[] so deque would be fine > here also. But maybe rewriting this patch to use ParagraphList::iterator > and algorithm::find would be better, wouldn't it? This way we won't rely > on vector property.
We heavily rely on operator[] being reasonably fast, i.e. O(1) maybe O(ln n). Certainly not O(n). > >>Like it is now, IMHO, lyx-1.4 is close to unusable under window. Is > >Andre had something that IIRC would replace the official insert() by a > >homegrown one, presumably faster. (What's the status of that?) > > I think it is possible to rewrite the ParagraphList class that would not > need the removal of the official insert(), only a cosmetic change. > IMHO, a good solution would be to use a list<Paragraph> member to store > the paragraphs and a vector<list<Paragraph>::iterator> for the > interface. This way ParagraphList::insert would call list::insert and > then update the vector or list iterator. I believe this would imply > minimal change to the code using ParagraphList; we would just need to > replace "insert(XXX.begin()+pos, Par)" with "insert(pos, Par)". Here is > a class prototype (not tested): > class ParagraphList > { > [...] > }; > > What do think? Ok if it works. Could be even faster than the custom swap-based insert() implmentation as swapping paragraphs is still slower than assigning Paragraph pointers. Andre'