OK, well, this may not be a huge issue, but looking closely at the Undo code, it is noticeable that we are creating a copy of the BufferParams for every undo operation, although---as the code says---this information is only USED for full-document operations. So that seems like a waste of memory (and time). Does this seems worth fixing while I'm at it? The only thing I can think to do here is something like the attached. Thoughts?

rh

Index: src/Undo.cpp
===================================================================
--- src/Undo.cpp	(revision 25525)
+++ src/Undo.cpp	(working copy)
@@ -73,8 +73,11 @@
 	            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)
-	{}
+	        pars(pl), array(ar), isFullBuffer(ifb)
+	{
+		bparams = new BufferParams(bp);
+	}
+	~UndoElement() { delete bparams; }
 	/// Which kind of operation are we recording for?
 	UndoKind kind;
 	/// the position of the cursor
@@ -90,7 +93,7 @@
 	/// the contents of the saved MathData (for mathed)
 	MathData * array;
 	/// Only used in case of full backups
-	BufferParams bparams;
+	BufferParams const * bparams;
 	/// Only used in case of full backups
 	bool isFullBuffer;
 private:
@@ -321,8 +324,9 @@
 	if (undo.isFullBuffer) {
 		LASSERT(undo.pars, /**/);
 		// This is a full document
-		otherstack.top().bparams = buffer_.params();
-		buffer_.params() = undo.bparams;
+		delete otherstack.top().bparams;
+		otherstack.top().bparams = new BufferParams(buffer_.params());
+		buffer_.params() = *undo.bparams;
 		swap(buffer_.paragraphs(), *undo.pars);
 		delete undo.pars;
 		undo.pars = 0;

Reply via email to