mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-09 18:31:04 +00:00
Micro-optimisation, avoid rightMargin() call in two loop.
* 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
This commit is contained in:
parent
4c765ba889
commit
12df886453
@ -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
|
||||
|
14
src/text.C
14
src/text.C
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user