[LyX/master] Remove a couple more functors from PrevewLoader.

Richard Kimberly Heck rikiheck at lyx.org
Wed May 13 17:13:30 UTC 2020


commit 47973dc2b448dd2753f0b55c057ceda9e349a5f1
Author: Richard Kimberly Heck <rikiheck at lyx.org>
Date:   Wed May 13 13:26:54 2020 -0400

    Remove a couple more functors from PrevewLoader.
---
 src/graphics/PreviewLoader.cpp |   44 +++++++++++++--------------------------
 1 files changed, 15 insertions(+), 29 deletions(-)

diff --git a/src/graphics/PreviewLoader.cpp b/src/graphics/PreviewLoader.cpp
index e83af70..76f634c 100644
--- a/src/graphics/PreviewLoader.cpp
+++ b/src/graphics/PreviewLoader.cpp
@@ -124,14 +124,10 @@ void setAscentFractions(vector<double> & ascent_fractions,
 }
 
 
-class FindFirst
+std::function <bool (SnippetPair const &)> FindFirst(string const & comp)
 {
-public:
-	FindFirst(string const & comp) : comp_(comp) {}
-	bool operator()(SnippetPair const & sp) const { return sp.first == comp_; }
-private:
-	string const comp_;
-};
+	return [comp](SnippetPair const & sp) { return sp.first == comp; };
+}
 
 
 /// Store info on a currently executing, forked process.
@@ -147,13 +143,13 @@ public:
 	void stop() const;
 
 	///
-	pid_t pid;
-	///
 	string command;
 	///
 	FileName metrics_file;
 	///
 	BitmapFile snippets;
+	///
+	pid_t pid;
 };
 
 typedef map<pid_t, InProgress>  InProgressProcesses;
@@ -322,35 +318,25 @@ Buffer const & PreviewLoader::buffer() const
 
 namespace {
 
-class IncrementedFileName {
-public:
-	IncrementedFileName(string const & to_format,
-			    string const & filename_base)
-		: to_format_(to_format), base_(filename_base), counter_(1)
-	{}
-
-	SnippetPair const operator()(string const & snippet)
+std::function<SnippetPair (string const &)> IncrementedFileName
+	(string const & to_format, string const & filename_base)
+{
+	return [to_format, filename_base](string const & snippet)
 	{
+		static int counter_ = 1;
 		ostringstream os;
-		os << base_ << counter_++ << '.' << to_format_;
+		os << filename_base << counter_++ << '.' << to_format;
 		string const file = os.str();
-
 		return make_pair(snippet, FileName(file));
-	}
-
-private:
-	string const & to_format_;
-	string const & base_;
-	int counter_;
-};
+	};
+}
 
 
 InProgress::InProgress(string const & filename_base,
 		       PendingSnippets const & pending,
 		       string const & to_format)
-	: pid(0),
-	  metrics_file(filename_base + ".metrics"),
-	  snippets(pending.size())
+	: metrics_file(filename_base + ".metrics"),
+	  snippets(pending.size()), pid(0)
 {
 	PendingSnippets::const_iterator pit  = pending.begin();
 	PendingSnippets::const_iterator pend = pending.end();


More information about the lyx-cvs mailing list