On Thu, Jun 14, 2007 at 05:05:32PM +0200, Stefan Schimanski wrote: > I did some profiling of paragraph drawing. 20% of the whole time > while inserting characters and redrawing the screen was taken by > Paragraph::getInset calls, each for every character. This is stupid. > See the patch below for a loop iterating over the insets of a > paragraph instead. O(insetnumber) instead of O(charnumber * ln > insetnumber). > > Stefan > > Index: src/rowpainter.cpp > =================================================================== > --- src/rowpainter.cpp (Revision 18765) > +++ src/rowpainter.cpp (Arbeitskopie) > @@ -958,10 +958,11 @@ > // done here. > // JSpitzm: We should aim at removing wide() altogether > while retaining > // typing speed within insets. > - for (pos_type i = rit->pos() ; i != rit->endpos(); ++i) { > - Inset const * const in = par.getInset(i); > - if (in) { > - InsetText * t = const_cast<InsetText > *>(in->asTextInset()); > + InsetList::const_iterator iit = > par.insetlist.insetIterator(rit->pos()); > + InsetList::const_iterator iend = par.insetlist.end(); > + for (; iit != iend && iit->pos < rit->endpos(); ++iit) { > + if (iit->inset) { > + InsetText * t = const_cast<InsetText > *>(iit->inset->asTextInset()); > if (t) > t->setWide(in_inset_alone_on_row > && leftEdgeFixed
Good catch. Patch is fine with me. [And I continue hating that wide() business ;-}] Andre'