From: Jean-Marc Lasgouttes Date: Fri, 19 Oct 2001 12:34:31 +0000 (+0000) Subject: speed up workWidth code X-Git-Tag: 1.6.10~20463 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=a80bee35b9ab3889d53410b2256df25f270768de;p=features.git speed up workWidth code git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2900 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/ChangeLog b/src/ChangeLog index e0e5449d89..d6a6ecf05d 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,9 @@ +2001-10-19 Jean-Marc Lasgouttes + + * text.C (workWidth): do not search for the exact row when + margintype is not MARGIN_RIGHT_ADDRESS_BOX. This is an + optimization for big documents. + 2001-10-18 Juergen Vigna * text.C (workWidth): new function with added Inset * parameter. diff --git a/src/text.C b/src/text.C index 731ae3282c..02afce8f7d 100644 --- a/src/text.C +++ b/src/text.C @@ -68,7 +68,7 @@ int LyXText::workWidth(BufferView * bview, Inset * inset) const { Buffer::inset_iterator it; Paragraph * par = 0; - Paragraph::size_type pos; + Paragraph::size_type pos = 0; for(it=bview->buffer()->inset_iterator_begin(); it != bview->buffer()->inset_iterator_end(); @@ -80,20 +80,38 @@ int LyXText::workWidth(BufferView * bview, Inset * inset) const break; } } - if (par) { + + if (!par) { + lyxerr << "LyXText::workWidth: cannot find inset!" <buffer()->params.textclass, + par->getLayout()); + + if (layout.margintype != MARGIN_RIGHT_ADDRESS_BOX) { + // Optimization here: in most cases, the real row is + // not needed, but only the par/pos values. So we just + // construct a dummy row for leftMargin. (JMarc) + Row dummyrow; + dummyrow.par(par); + dummyrow.pos(pos); + return workWidth(bview) - leftMargin(bview, &dummyrow); + } else { Row * row = firstrow; for(; row; row = row->next()) { if ((row->par() == par && row->pos() >= pos)) { if (!row->next()) break; else if ((row->next()->par() == par) && - (row->next()->pos() >= pos)) + (row->next()->pos() >= pos)) continue; } } if (row) { return workWidth(bview) - leftMargin(bview, row); - } + } } return workWidth(bview); }