]> git.lyx.org Git - features.git/commitdiff
Micro-optimisation, avoid rightMargin() call in two loop.
authorAbdelrazak Younes <younes@lyx.org>
Wed, 8 Nov 2006 11:27:06 +0000 (11:27 +0000)
committerAbdelrazak Younes <younes@lyx.org>
Wed, 8 Nov 2006 11:27:06 +0000 (11:27 +0000)
* LyXText:
  - rowBreakPoint(): now requires the right margin value.
  - redoParagraph(): factorize rightMargin() call from two loops.
  - editXY(): add doxygen comments.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@15802 a592a061-630c-0410-9148-cb99ea01b6c8

src/lyxtext.h
src/text.C

index 75cb8021144e4c227a23e6b7848d12e05d2257f1..e9303fe37aafdf5cd2a76a45d73a1b8b16ac0b1d 100644 (file)
@@ -178,8 +178,15 @@ public:
        void recUndo(LCursor & cur, pit_type first) const;
        /// returns true if par was empty and was removed
        bool setCursorFromCoordinates(LCursor & cur, int x, int y);
-       ///
+
+       /// sets cursor recursively descending into nested editable insets
+       /**
+       \return the inset pointer if x,y is covering that inset
+       \param x,y are absolute screen coordinates.
+       \retval inset is non-null if the cursor is positionned inside
+       */
        InsetBase * editXY(LCursor & cur, int x, int y);
+       
        /// Move cursor one line up.
        /**
         * Returns true if an update is needed after the move.
@@ -383,7 +390,8 @@ private:
 
        /// sets row.end to the pos value *after* which a row should break.
        /// for example, the pos after which isNewLine(pos) == true
-       void rowBreakPoint(Buffer const &, pit_type pit, Row & row) const;
+       void rowBreakPoint(Buffer const &, int right_margin, pit_type pit,
+               Row & row) const;
        /// sets row.width to the minimum space a row needs on the screen in pixel
        void setRowWidth(Buffer const &, pit_type pit, Row & row) const;
        /// the minimum space a manual label needs on the screen in pixels
index d26b5a4875bb56484d74072c891485807025fe24..eb7195732a5e8aeafbdafdf360b0a1dc9048bfab 100644 (file)
@@ -695,8 +695,8 @@ pos_type addressBreakPoint(pos_type i, Paragraph const & par)
 };
 
 
-void LyXText::rowBreakPoint(Buffer const & buffer, pit_type const pit,
-               Row & row) const
+void LyXText::rowBreakPoint(Buffer const & buffer, int right_margin,
+               pit_type const pit,     Row & row) const
 {
        Paragraph const & par = pars_[pit];
        pos_type const end = par.size();
@@ -707,7 +707,7 @@ void LyXText::rowBreakPoint(Buffer const & buffer, pit_type const pit,
        }
 
        // maximum pixel width of a row
-       int width = maxwidth_ - rightMargin(buffer, par); // - leftMargin(buffer, pit, row);
+       int width = maxwidth_ - right_margin; // - leftMargin(buffer, pit, row);
        if (width < 0) {
                row.endpos(end);
                return;
@@ -1837,6 +1837,10 @@ bool LyXText::redoParagraph(BufferView & bv, pit_type const pit)
                }
        }
 
+       // Optimisation: this is used in the next two loops
+       // so better to calculate that once here.
+       int right_margin = rightMargin(buffer, par);
+
        // redo insets
        // FIXME: We should always use getFont(), see documentation of
        // noFontChange() in insetbase.h.
@@ -1846,7 +1850,7 @@ bool LyXText::redoParagraph(BufferView & bv, pit_type const pit)
        for (; ii != iend; ++ii) {
                Dimension dim;
                int const w = maxwidth_ - leftMargin(buffer, pit, ii->pos)
-                       - rightMargin(buffer, par);
+                       - right_margin;
                LyXFont const & font = ii->inset->noFontChange() ?
                        bufferfont :
                        getFont(buffer, par, ii->pos);
@@ -1862,7 +1866,7 @@ bool LyXText::redoParagraph(BufferView & bv, pit_type const pit)
        pos_type z = 0;
        do {
                Row row(z);
-               rowBreakPoint(buffer, pit, row);
+               rowBreakPoint(buffer, right_margin, pit, row);
                setRowWidth(buffer, pit, row);
                setHeightOfRow(bv, pit, row);
                par.rows().push_back(row);