Martin Vermeer <[EMAIL PROTECTED]> writes:

| Attached, finally, the corrected version of the patch using crc32. Turns
| out y isn't needed here after all.

Any noticble speed difference?

| Index: rowpainter.C
| ===================================================================
| RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/rowpainter.C,v
| retrieving revision 1.160
| diff -u -p -r1.160 rowpainter.C
| --- rowpainter.C      17 Dec 2005 15:03:39 -0000      1.160
| +++ rowpainter.C      29 Dec 2005 20:58:36 -0000
| @@ -40,6 +40,8 @@
|  
|  #include "support/textutils.h"
|  
| +#include <boost/crc.hpp>
| +
|  using lyx::pos_type;
|  using lyx::pit_type;
|  
| @@ -717,7 +719,8 @@ void RowPainter::paintText()
|  
|  
|  void paintPar
| -     (PainterInfo & pi, LyXText const & text, pit_type pit, int x, int y)
| +     (PainterInfo & pi, LyXText const & text, pit_type pit, int x, int y,
| +      bool repaintAll)
|  {
|  //   lyxerr << "  paintPar: pit: " << pit << " at y: " << y << endl;
|       static NullPainter nop;
| @@ -731,22 +734,67 @@ void paintPar
|       theCoords.parPos()[&text][pit] = Point(x, y);
|  
|       y -= rb->ascent();
| -     for (RowList::const_iterator rit = rb; rit != re; ++rit) {
| +     lyx::size_type rowno(0);
| +     for (RowList::const_iterator rit = rb; rit != re; ++rit, ++rowno) {
|               y += rit->ascent();
|               bool const inside = (y + rit->descent() >= 0
|                                      && y - rit->ascent() < ww);
|               RowPainter rp(inside ? pi : nullpi, text, pit, *rit, x, y);
|  
|               y += rit->descent();
| -             rp.paintAppendix();
| -             rp.paintDepthBar();
| -             rp.paintChangeBar();
| -             if (rit == rb)
| -                     rp.paintFirst();
| -             if (rit + 1 == re)
| -                     rp.paintLast();
| -             rp.paintText();
| +
| +             // Row signature; has row changed since last paint?
| +             boost::crc_32_type crc;
| +             for (lyx::pos_type i = rit->pos(); i < rit->endpos(); ++i) {
| +                     const unsigned char b[] = { par.getChar(i) };
| +                     crc.process_bytes(b, 1);
| +             }                   
| +             lyx::size_type const row_sig = crc.checksum();

Please refactor a bit:

lyx::size_type calculateRowSignature(Row const & row)
{
        boost::crc_32_type crc;
        for (lyx::pos_type i = row.pos(); i < row.endpos(); ++i) {
                const unsigned char b[] = { par.getChar(i) };
                crc.process_bytes(b, 1);
        }                   
        return crc.checksum();
}

lyx::size_type const row_sig = calculateRowSignagure(*rit);

| +
| +             // The following code figures out if the cursor is inside
| +             // an inset _on this row_.
| +             bool cur_in_inset_in_row(false);
| +             InsetList::const_iterator ii = par.insetlist.begin();
| +             InsetList::const_iterator iend = par.insetlist.end();
| +             for ( ; ii != iend; ++ii) {
| +                     if (ii->pos >= rit->pos() && ii->pos < rit->endpos()
| +                         && ii->inset->isTextInset() 
| +                         && pi.base.bv->cursor().isInside(ii->inset))
| +                             cur_in_inset_in_row = true;
| +                             break;
| +             }

This one as well.

bool isCursorInInsetInRow(...)
{
...
}

bool cur_in_inset_in_row = isCursorInInsetInRow(...);

(something)


-- 
        Lgb

Reply via email to