Fix bug 5010, for the most part. There's no need to construct a default UndoElement,

which involves constructing a default BufferParams (this is expensive), only then to
over-write everything. 


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@25522 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Richard Heck 2008-07-09 18:42:41 +00:00
parent f0c81b243f
commit 9aa5b42262

View File

@ -66,6 +66,15 @@ where to insert the stored bits when performining undo.
struct UndoElement
{
///
UndoElement(UndoKind kin, StableDocIterator const & cur,
StableDocIterator const & cel,
pit_type fro, pit_type en, ParagraphList * pl,
MathData * ar, BufferParams const & bp,
bool ifb) :
kind(kin), cursor(cur), cell(cel), from(fro), end(en),
pars(pl), array(ar), bparams(bp), isFullBuffer(ifb)
{}
/// Which kind of operation are we recording for?
UndoKind kind;
/// the position of the cursor
@ -84,6 +93,9 @@ struct UndoElement
BufferParams bparams;
/// Only used in case of full backups
bool isFullBuffer;
private:
/// Protect construction
UndoElement();
};
@ -216,20 +228,8 @@ void Undo::Private::doRecordUndo(UndoKind kind,
if (first_pit > last_pit)
swap(first_pit, last_pit);
// create the position information of the Undo entry
UndoElement undo;
undo.array = 0;
undo.pars = 0;
undo.kind = kind;
undo.cell = cell;
undo.cursor = cur;
undo.bparams = buffer_.params();
undo.isFullBuffer = isFullBuffer;
//lyxerr << "recordUndo: cur: " << cur << endl;
//lyxerr << "recordUndo: pos: " << cur.pos() << endl;
//lyxerr << "recordUndo: cell: " << cell << endl;
undo.from = first_pit;
undo.end = cell.lastpit() - last_pit;
UndoElement undo(kind, cur, cell, first_pit, cell.lastpit() - last_pit, 0, 0,
buffer_.params(), isFullBuffer);
UndoElementStack & stack = isUndoOperation ? undostack_ : redostack_;
// Undo::ATOMIC are always recorded (no overlapping there).