[LyX/master] Use range and rename private variable

Richard Kimberly Heck rikiheck at lyx.org
Fri Feb 28 05:55:07 UTC 2020


commit 83779e79724dbf9b3bdb8e1d6bfc7663948db95d
Author: Richard Kimberly Heck <rikiheck at lyx.org>
Date:   Fri Feb 28 01:08:28 2020 -0500

    Use range and rename private variable
---
 src/BranchList.cpp |   31 +++++++++++++++----------------
 src/BranchList.h   |   10 +++++-----
 2 files changed, 20 insertions(+), 21 deletions(-)

diff --git a/src/BranchList.cpp b/src/BranchList.cpp
index ec6a413..9c0078b 100644
--- a/src/BranchList.cpp
+++ b/src/BranchList.cpp
@@ -125,16 +125,16 @@ void Branch::setColor(string const & str)
 Branch * BranchList::find(docstring const & name)
 {
 	List::iterator it =
-		find_if(list.begin(), list.end(), BranchNamesEqual(name));
-	return it == list.end() ? 0 : &*it;
+		find_if(list_.begin(), list_.end(), BranchNamesEqual(name));
+	return it == list_.end() ? 0 : &*it;
 }
 
 
 Branch const * BranchList::find(docstring const & name) const
 {
 	List::const_iterator it =
-		find_if(list.begin(), list.end(), BranchNamesEqual(name));
-	return it == list.end() ? 0 : &*it;
+		find_if(list_.begin(), list_.end(), BranchNamesEqual(name));
+	return it == list_.end() ? 0 : &*it;
 }
 
 
@@ -151,15 +151,15 @@ bool BranchList::add(docstring const & s)
 			name = s.substr(i, j - i);
 		// Is this name already in the list?
 		bool const already =
-			find_if(list.begin(), list.end(),
-				     BranchNamesEqual(name)) != list.end();
+			find_if(list_.begin(), list_.end(),
+					 BranchNamesEqual(name)) != list_.end();
 		if (!already) {
 			added = true;
 			Branch br;
 			br.setBranch(name);
 			br.setSelected(false);
 			br.setFileNameSuffix(false);
-			list.push_back(br);
+			list_.push_back(br);
 		}
 		if (j == docstring::npos)
 			break;
@@ -171,9 +171,9 @@ bool BranchList::add(docstring const & s)
 
 bool BranchList::remove(docstring const & s)
 {
-	size_t const size = list.size();
-	list.remove_if(BranchNamesEqual(s));
-	return size != list.size();
+	size_t const size = list_.size();
+	list_.remove_if(BranchNamesEqual(s));
+	return size != list_.size();
 }
 
 
@@ -182,8 +182,8 @@ bool BranchList::rename(docstring const & oldname,
 {
 	if (newname.empty())
 		return false;
-	if (find_if(list.begin(), list.end(),
-		    BranchNamesEqual(newname)) != list.end()) {
+	if (find_if(list_.begin(), list_.end(),
+			BranchNamesEqual(newname)) != list_.end()) {
 		// new name already taken
 		if (merge)
 		      return remove(oldname);
@@ -201,10 +201,9 @@ bool BranchList::rename(docstring const & oldname,
 docstring BranchList::getFileNameSuffix() const
 {
 	docstring result;
-	List::const_iterator it = list.begin();
-	for (; it != list.end(); ++it) {
-		if (it->isSelected() && it->hasFileNameSuffix())
-			result += "-" + it->branch();
+	for (auto const & br : list_) {
+		if (br.isSelected() && br.hasFileNameSuffix())
+			result += "-" + br.branch();
 	}
 	return support::subst(result, from_ascii("/"), from_ascii("_"));
 }
diff --git a/src/BranchList.h b/src/BranchList.h
index e3e18e1..534fb87 100644
--- a/src/BranchList.h
+++ b/src/BranchList.h
@@ -97,12 +97,12 @@ public:
 	docstring separator() const { return separator_; }
 
 	///
-	bool empty() const { return list.empty(); }
+	bool empty() const { return list_.empty(); }
 	///
-	void clear() { list.clear(); }
+	void clear() { list_.clear(); }
 	///
-	const_iterator begin() const { return list.begin(); }
-	const_iterator end() const { return list.end(); }
+	const_iterator begin() const { return list_.begin(); }
+	const_iterator end() const { return list_.end(); }
 
 	/** \returns the Branch with \c name. If not found, returns 0.
 	 */
@@ -128,7 +128,7 @@ public:
 
 private:
 	///
-	List list;
+	List list_;
 	///
 	docstring separator_;
 };


More information about the lyx-cvs mailing list