Hi,

another patch for the change tracking branch. This time, I turned Paragraph::Pimpl:changes_ into an object (before it has been a pointer).

I think this is the last "mechanical" patch. The next one will be a bit more exciting.

Michael


Index: paragraph_pimpl.C
===================================================================
--- paragraph_pimpl.C	(Revision 13830)
+++ paragraph_pimpl.C	(Arbeitskopie)
@@ -62,7 +62,7 @@
 
 
 Paragraph::Pimpl::Pimpl(Paragraph * owner)
-	: owner_(owner)
+	: changes_(Change::UNCHANGED), owner_(owner)
 {
 	inset_owner = 0;
 	id_ = paragraph_id++;
@@ -70,20 +70,18 @@
 
 
 Paragraph::Pimpl::Pimpl(Pimpl const & p, Paragraph * owner)
-	: params(p.params), owner_(owner)
+	: params(p.params), changes_(p.changes_), owner_(owner)
 {
 	inset_owner = p.inset_owner;
 	fontlist = p.fontlist;
 	id_ = paragraph_id++;
-
-	changes_.reset(new Changes(*p.changes_.get()));
 }
 
 
 void Paragraph::Pimpl::setContentsFromPar(Paragraph const & par)
 {
 	owner_->text_ = par.text_;
-	changes_.reset(new Changes(*(par.pimpl_->changes_.get())));
+	changes_ = Changes(par.pimpl_->changes_);
 }
 
 
@@ -104,26 +102,26 @@
 	}
 	
 	// in a buffer where ct is enabled, set everything to INSERTED
-	changes_.reset(new Changes(Change::INSERTED));
-	changes_->set(Change::INSERTED, 0, size() + 1);
+	changes_ = Changes(Change::INSERTED);
+	changes_.set(Change::INSERTED, 0, size() + 1);
 }
 
 
 bool Paragraph::Pimpl::isChanged(pos_type start, pos_type end) const
 {
-	return changes_->isChange(start, end);
+	return changes_.isChange(start, end);
 }
 
 
 bool Paragraph::Pimpl::isChangeEdited(pos_type start, pos_type end) const
 {
-	return changes_->isChangeEdited(start, end);
+	return changes_.isChangeEdited(start, end);
 }
 
 
 void Paragraph::Pimpl::setChangeType(pos_type pos, Change::Type type)
 {
-	changes_->set(type, pos);
+	changes_.set(type, pos);
 }
 
 
@@ -136,7 +134,7 @@
 		case Change::UNCHANGED:
 		case Change::INSERTED:
 			for (pos_type i = 0; i < size(); ++i) {
-				changes_->set(type, i);
+				changes_.set(type, i);
 				if (owner_->isInset(i))
 					owner_->getInset(i)->setChangeType(type);
 			}
@@ -149,20 +147,20 @@
 
 void Paragraph::Pimpl::setChange(pos_type pos, Change const & change)
 {
-	changes_->set(change, pos);
+	changes_.set(change, pos);
 }
 
 
 Change const Paragraph::Pimpl::lookupChange(pos_type pos) const
 {
-	return changes_->lookup(pos);
+	return changes_.lookup(pos);
 }
 
 
 void Paragraph::Pimpl::acceptChange(pos_type start, pos_type end)
 {
 	if (!size()) {
-		changes_.reset(new Changes(Change::UNCHANGED));
+		changes_ = Changes(Change::UNCHANGED);
 		return;
 	}
 
@@ -175,7 +173,7 @@
 				break;
 
 			case Change::INSERTED:
-				changes_->set(Change::UNCHANGED, i);
+				changes_.set(Change::UNCHANGED, i);
 				break;
 
 			case Change::DELETED:
@@ -183,7 +181,7 @@
 				// "end-of-paragraph char":
 				if (i < size()) {
 					eraseIntern(i);
-					changes_->erase(i);
+					changes_.erase(i);
 					--end;
 					--i;
 				}
@@ -192,14 +190,14 @@
 	}
 
 	lyxerr[Debug::CHANGES] << "endacceptchange" << endl;
-	changes_->reset(Change::UNCHANGED);
+	changes_.reset(Change::UNCHANGED);
 }
 
 
 void Paragraph::Pimpl::rejectChange(pos_type start, pos_type end)
 {
 	if (!size()) {
-		changes_.reset(new Changes(Change::UNCHANGED));
+		changes_ = Changes(Change::UNCHANGED);
 		return;
 	}
 
@@ -213,21 +211,21 @@
 			case Change::INSERTED:
 				if (i < size()) {
 					eraseIntern(i);
-					changes_->erase(i);
+					changes_.erase(i);
 					--end;
 					--i;
 				}
 				break;
 
 			case Change::DELETED:
-				changes_->set(Change::UNCHANGED, i);
+				changes_.set(Change::UNCHANGED, i);
 				// No real char at position size():
 				if (i < size() && owner_->isInset(i))
 					owner_->getInset(i)->setChangeType(Change::UNCHANGED);
 				break;
 		}
 	}
-	changes_->reset(Change::UNCHANGED);
+	changes_.reset(Change::UNCHANGED);
 }
 
 
@@ -241,7 +239,7 @@
 {
 	BOOST_ASSERT(pos <= size());
 
-	changes_->record(change, pos);
+	changes_.record(change, pos);
 
 	// This is actually very common when parsing buffers (and
 	// maybe inserting ascii text)
@@ -334,8 +332,8 @@
 #ifdef WITH_WARNINGS
 #warning MG: The whole logic of this method will be changed soon
 #endif
-		Change::Type changetype(changes_->lookup(pos).type);
-		changes_->record(Change(Change::DELETED), pos);
+		Change::Type changetype(changes_.lookup(pos).type);
+		changes_.record(Change(Change::DELETED), pos);
 
 		// only allow the actual removal if it was /new/ text
 		if (changetype != Change::INSERTED) {
Index: paragraph_pimpl.h
===================================================================
--- paragraph_pimpl.h	(Revision 13830)
+++ paragraph_pimpl.h	(Arbeitskopie)
@@ -165,8 +165,8 @@
 	/// match a string against a particular point in the paragraph
 	bool isTextAt(std::string const & str, lyx::pos_type pos) const;
 
-	/// for recording and looking up changes in revision tracking mode
-	boost::scoped_ptr<Changes> changes_;
+	/// for recording and looking up changes
+	Changes changes_;
 
 	/// Who owns us?
 	Paragraph * owner_;

Reply via email to