Refactoring patches

Yuriy Skalko yuriy.skalko at gmail.com
Fri Oct 16 07:56:02 UTC 2020


And here are new refactoring patches.

Yuriy
-------------- next part --------------
From 02bd84a72dc9ee134204eee5ce750e8bf107c561 Mon Sep 17 00:00:00 2001
From: Yuriy Skalko <yuriy.skalko at gmail.com>
Date: Thu, 15 Oct 2020 12:00:48 +0300
Subject: [PATCH 1/3] Clean math headers

---
 src/mathed/MathRow.h    | 3 +--
 src/mathed/MathStream.h | 1 -
 2 files changed, 1 insertion(+), 3 deletions(-)

diff --git a/src/mathed/MathRow.h b/src/mathed/MathRow.h
index f2b0445a0b..d985569f46 100644
--- a/src/mathed/MathRow.h
+++ b/src/mathed/MathRow.h
@@ -26,11 +26,10 @@ namespace lyx {
 
 class BufferView;
 class Dimension;
+class MathData;
 class MetricsInfo;
 class PainterInfo;
 
-class InsetMath;
-class MathData;
 
 /*
  * While for editing purpose it is important that macros are counted
diff --git a/src/mathed/MathStream.h b/src/mathed/MathStream.h
index 1d7e1de424..db4a499a0f 100644
--- a/src/mathed/MathStream.h
+++ b/src/mathed/MathStream.h
@@ -25,7 +25,6 @@
 namespace lyx {
 
 class Encoding;
-class InsetMath;
 class MathAtom;
 class MathData;
 
-- 
2.28.0.windows.1

-------------- next part --------------
From bd9cc7821f9368e293499c53275ec3fd9ff7dbd6 Mon Sep 17 00:00:00 2001
From: Yuriy Skalko <yuriy.skalko at gmail.com>
Date: Fri, 16 Oct 2020 09:55:42 +0300
Subject: [PATCH 2/3] Remove unused headers in output_xhtml.h

---
 src/output_xhtml.h | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/src/output_xhtml.h b/src/output_xhtml.h
index 8a5b63a02c..e9ca2716b8 100644
--- a/src/output_xhtml.h
+++ b/src/output_xhtml.h
@@ -17,9 +17,6 @@
 #include "support/strfwd.h"
 #include "xml.h"
 
-#include <deque>
-#include <memory>
-
 
 namespace lyx {
 
-- 
2.28.0.windows.1

-------------- next part --------------
From a921c0f6b9ef5cf7ded61b5f05d78f72d2149d05 Mon Sep 17 00:00:00 2001
From: Yuriy Skalko <yuriy.skalko at gmail.com>
Date: Fri, 16 Oct 2020 10:19:34 +0300
Subject: [PATCH 3/3] Remove redundant `const &` for primitive types

---
 src/BufferView.cpp                  | 2 +-
 src/BufferView.h                    | 2 +-
 src/Encoding.cpp                    | 4 ++--
 src/Encoding.h                      | 4 ++--
 src/Font.cpp                        | 6 +++---
 src/Font.h                          | 6 +++---
 src/LaTeXFonts.cpp                  | 3 +--
 src/LaTeXFonts.h                    | 2 +-
 src/TextClass.h                     | 2 +-
 src/frontends/alert.h               | 2 +-
 src/frontends/qt/FloatPlacement.cpp | 2 +-
 src/frontends/qt/FloatPlacement.h   | 2 +-
 src/frontends/qt/GuiAlert.cpp       | 4 ++--
 src/frontends/qt/qt_helpers.cpp     | 2 +-
 src/frontends/qt/qt_helpers.h       | 2 +-
 src/tests/check_layout.cpp          | 2 +-
 src/tex2lyx/Parser.cpp              | 2 +-
 src/tex2lyx/Parser.h                | 2 +-
 src/tex2lyx/dummy_impl.cpp          | 3 +--
 19 files changed, 26 insertions(+), 28 deletions(-)

diff --git a/src/BufferView.cpp b/src/BufferView.cpp
index 576bc67811..88fe8fa023 100644
--- a/src/BufferView.cpp
+++ b/src/BufferView.cpp
@@ -3410,7 +3410,7 @@ docstring const & BufferView::inlineCompletion() const
 }
 
 
-size_t const & BufferView::inlineCompletionUniqueChars() const
+size_t BufferView::inlineCompletionUniqueChars() const
 {
 	return d->inlineCompletionUniqueChars_;
 }
diff --git a/src/BufferView.h b/src/BufferView.h
index 4a020eb3b2..22f0d92765 100644
--- a/src/BufferView.h
+++ b/src/BufferView.h
@@ -219,7 +219,7 @@ public:
 	/// return the inline completion postfix.
 	docstring const & inlineCompletion() const;
 	/// return the number of unique characters in the inline completion.
-	size_t const & inlineCompletionUniqueChars() const;
+	size_t inlineCompletionUniqueChars() const;
 	/// return the position in the buffer of the inline completion postfix.
 	DocIterator const & inlineCompletionPos() const;
 	/// make sure inline completion position is OK
diff --git a/src/Encoding.cpp b/src/Encoding.cpp
index 64bb3c0b64..4dcede47b5 100644
--- a/src/Encoding.cpp
+++ b/src/Encoding.cpp
@@ -643,7 +643,7 @@ Encodings::fromLyXName(string const & name, bool allowUnsafe) const
 
 
 Encoding const *
-Encodings::fromLaTeXName(string const & n, int const & p, bool allowUnsafe) const
+Encodings::fromLaTeXName(string const & n, int p, bool allowUnsafe) const
 {
 	string name = n;
 	// FIXME: if we have to test for too many of these synonyms,
@@ -666,7 +666,7 @@ Encodings::fromLaTeXName(string const & n, int const & p, bool allowUnsafe) cons
 
 
 Encoding const *
-Encodings::fromIconvName(string const & n, int const & p, bool allowUnsafe) const
+Encodings::fromIconvName(string const & n, int p, bool allowUnsafe) const
 {
 	EncodingList::const_iterator const end = encodinglist.end();
 	for (EncodingList::const_iterator it = encodinglist.begin(); it != end; ++it)
diff --git a/src/Encoding.h b/src/Encoding.h
index 76b022dd9d..6a96843607 100644
--- a/src/Encoding.h
+++ b/src/Encoding.h
@@ -255,10 +255,10 @@ public:
 	fromLyXName(std::string const & name, bool allowUnsafe = false) const;
 	/// Get encoding from LaTeX name \p name and package \p package
 	Encoding const * fromLaTeXName(std::string const & name,
-		int const & package = Encoding::any, bool allowUnsafe = false) const;
+		int package = Encoding::any, bool allowUnsafe = false) const;
 	/// Get encoding from iconv name \p name and package \p package
 	Encoding const * fromIconvName(std::string const & name,
-		int const & package = Encoding::any, bool allowUnsafe = false) const;
+		int package = Encoding::any, bool allowUnsafe = false) const;
 
 	///
 	const_iterator begin() const { return encodinglist.begin(); }
diff --git a/src/Font.cpp b/src/Font.cpp
index fda0854fe1..aed80592a5 100644
--- a/src/Font.cpp
+++ b/src/Font.cpp
@@ -228,8 +228,8 @@ int Font::latexWriteStartChanges(otexstream & os, BufferParams const & bparams,
 				    OutputParams const & runparams,
 				    Font const & base,
 				    Font const & prev,
-				    bool const & non_inherit_inset,
-				    bool const & needs_cprotection) const
+				    bool non_inherit_inset,
+				    bool needs_cprotection) const
 {
 	int count = 0;
 
@@ -522,7 +522,7 @@ int Font::latexWriteEndChanges(otexstream & os, BufferParams const & bparams,
 				  Font const & base,
 				  Font const & next,
 				  bool & needPar,
-				  bool const & closeLanguage) const
+				  bool closeLanguage) const
 {
 	int count = 0;
 
diff --git a/src/Font.h b/src/Font.h
index 9b08c8387c..fdcdb7d3e3 100644
--- a/src/Font.h
+++ b/src/Font.h
@@ -76,8 +76,8 @@ public:
 				   OutputParams const & runparams,
 				   Font const & base,
 				   Font const & prev,
-				   bool const & non_inherit_inset = false,
-				   bool const & needs_cprotection = false) const;
+				   bool non_inherit_inset = false,
+				   bool needs_cprotection = false) const;
 
 	/** Writes the tail of the LaTeX needed to change to this font.
 	    Returns number of chars written. Base is the font state we want
@@ -88,7 +88,7 @@ public:
 				 Font const & base,
 				 Font const & next,
 				 bool & needPar,
-				 bool const & closeLanguage = true) const;
+				 bool closeLanguage = true) const;
 
 
 	/// Build GUI description of font state
diff --git a/src/LaTeXFonts.cpp b/src/LaTeXFonts.cpp
index 16470cc2d9..d28a7d2930 100644
--- a/src/LaTeXFonts.cpp
+++ b/src/LaTeXFonts.cpp
@@ -292,8 +292,7 @@ string const LaTeXFont::getPackageOptions(bool ot1, bool complete, bool sc, bool
 
 
 string const LaTeXFont::getLaTeXCode(bool dryrun, bool ot1, bool complete, bool sc,
-				     bool osf, bool nomath, string const & extraopts,
-				     int const & scale)
+				     bool osf, bool nomath, string const & extraopts, int scale)
 {
 	ostringstream os;
 
diff --git a/src/LaTeXFonts.h b/src/LaTeXFonts.h
index 116ef082c7..1da7d06e4f 100644
--- a/src/LaTeXFonts.h
+++ b/src/LaTeXFonts.h
@@ -90,7 +90,7 @@ public:
 	std::string const getLaTeXCode(bool dryrun, bool ot1, bool complete,
 				       bool sc, bool osf, bool nomath,
 				       std::string const & extraopts = std::string(),
-				       int const & scale = 100);
+				       int scale = 100);
 	/// Return the actually used font
 	docstring const getUsedFont(bool ot1, bool complete, bool nomath, bool osf);
 	/// Return the actually used package
diff --git a/src/TextClass.h b/src/TextClass.h
index 6ba185aa9c..5314f391fb 100644
--- a/src/TextClass.h
+++ b/src/TextClass.h
@@ -490,7 +490,7 @@ public:
 	///
 	docstring const & htmlstyles() const { return htmlstyles_; }
 	///
-	bool const & docbookforceabstract() const { return docbookforceabstract_; }
+	bool docbookforceabstract() const { return docbookforceabstract_; }
 	///
 	std::string const & docbookroot() const { return docbookroot_; }
 	/// Looks for the layout of "highest level", other than Part (or other
diff --git a/src/frontends/alert.h b/src/frontends/alert.h
index c3b8065f98..20da43656a 100644
--- a/src/frontends/alert.h
+++ b/src/frontends/alert.h
@@ -45,7 +45,7 @@ int prompt(docstring const & title, docstring const & question,
  * The console output takes care of converting any Qt html to plain text.
  */
 void warning(docstring const & title, docstring const & message,
-	     bool const & askshowagain = false);
+	     bool askshowagain = false);
 
 /**
  * Display a warning to the user. Title should be a short (general) summary.
diff --git a/src/frontends/qt/FloatPlacement.cpp b/src/frontends/qt/FloatPlacement.cpp
index d11458716f..21d13e9c3b 100644
--- a/src/frontends/qt/FloatPlacement.cpp
+++ b/src/frontends/qt/FloatPlacement.cpp
@@ -89,7 +89,7 @@ void FloatPlacement::useSideways()
 }
 
 
-bool FloatPlacement::possiblePlacement(char const & p) const
+bool FloatPlacement::possiblePlacement(char p) const
 {
 	return !spanCB->isVisible() || contains(allowed_placement_, p);
 }
diff --git a/src/frontends/qt/FloatPlacement.h b/src/frontends/qt/FloatPlacement.h
index ebcd8b672a..96d45dfc45 100644
--- a/src/frontends/qt/FloatPlacement.h
+++ b/src/frontends/qt/FloatPlacement.h
@@ -65,7 +65,7 @@ private:
 	///
 	void initFloatPlacementCO(bool const);
 	///
-	bool possiblePlacement(char const & p) const;
+	bool possiblePlacement(char p) const;
 
 	/// one of figure or table?
 	bool standardfloat_;
diff --git a/src/frontends/qt/GuiAlert.cpp b/src/frontends/qt/GuiAlert.cpp
index ce696cb2bb..93b8e1d4e6 100644
--- a/src/frontends/qt/GuiAlert.cpp
+++ b/src/frontends/qt/GuiAlert.cpp
@@ -150,7 +150,7 @@ int prompt(docstring const & title, docstring const & question,
 }
 
 void doWarning(docstring const & title, docstring const & message,
-	     bool const & askshowagain)
+	     bool askshowagain)
 {
 	lyxerr << "Warning: " << toPlainText(title) << '\n'
 	       << "----------------------------------------\n"
@@ -190,7 +190,7 @@ void doWarning(docstring const & title, docstring const & message,
 }
 
 void warning(docstring const & title, docstring const & message,
-	     bool const & askshowagain)
+	     bool askshowagain)
 {
 #ifdef EXPORT_in_THREAD
 	InGuiThread<void>().call(&doWarning,
diff --git a/src/frontends/qt/qt_helpers.cpp b/src/frontends/qt/qt_helpers.cpp
index fc1f961b5a..2a35897451 100644
--- a/src/frontends/qt/qt_helpers.cpp
+++ b/src/frontends/qt/qt_helpers.cpp
@@ -198,7 +198,7 @@ string widgetToDoubleStr(QLineEdit const * input)
 }
 
 
-void doubleToWidget(QLineEdit * input, double const & value, char f, int prec)
+void doubleToWidget(QLineEdit * input, double value, char f, int prec)
 {
 	QLocale loc;
 	loc.setNumberOptions(QLocale::OmitGroupSeparator);
diff --git a/src/frontends/qt/qt_helpers.h b/src/frontends/qt/qt_helpers.h
index aff144b055..92c72f3b26 100644
--- a/src/frontends/qt/qt_helpers.h
+++ b/src/frontends/qt/qt_helpers.h
@@ -61,7 +61,7 @@ double widgetToDouble(QLineEdit const * input);
 /// method to get a double value from a localized widget (QLineEdit)
 std::string widgetToDoubleStr(QLineEdit const * input);
 /// method to set a (localized) double value in a widget (QLineEdit)
-void doubleToWidget(QLineEdit * input, double const & value,
+void doubleToWidget(QLineEdit * input, double value,
 	char f = 'g', int prec = 6);
 /// method to set a (localized) double value in a widget (QLineEdit)
 void doubleToWidget(QLineEdit * input, std::string const & value,
diff --git a/src/tests/check_layout.cpp b/src/tests/check_layout.cpp
index 2fa0fe11e9..039d51b222 100644
--- a/src/tests/check_layout.cpp
+++ b/src/tests/check_layout.cpp
@@ -20,7 +20,7 @@ using namespace std;
 namespace lyx {
 namespace frontend {
 namespace Alert {
-void warning(docstring const & title, docstring const & message, bool const &)
+void warning(docstring const & title, docstring const & message, bool)
 {
 	LYXERR0(title);
 	LYXERR0(message);
diff --git a/src/tex2lyx/Parser.cpp b/src/tex2lyx/Parser.cpp
index e44aa3e69a..62cab06fba 100644
--- a/src/tex2lyx/Parser.cpp
+++ b/src/tex2lyx/Parser.cpp
@@ -196,7 +196,7 @@ void Parser::deparse()
 }
 
 
-bool Parser::setEncoding(std::string const & e, int const & p)
+bool Parser::setEncoding(std::string const & e, int p)
 {
 	// We may (and need to) use unsafe encodings here: Since the text is
 	// converted to unicode while reading from is_, we never see text in
diff --git a/src/tex2lyx/Parser.h b/src/tex2lyx/Parser.h
index e9afbd19d9..ada6b5f72a 100644
--- a/src/tex2lyx/Parser.h
+++ b/src/tex2lyx/Parser.h
@@ -187,7 +187,7 @@ public:
 
 	/// change the encoding of the input stream according to \p encoding
 	/// (latex name) and package \p package
-	bool setEncoding(std::string const & encoding, int const & package);
+	bool setEncoding(std::string const & encoding, int package);
 	/// change the encoding of the input stream to \p encoding (iconv name)
 	bool setEncoding(std::string const & encoding);
 	/// get the current iconv encoding of the input stream
diff --git a/src/tex2lyx/dummy_impl.cpp b/src/tex2lyx/dummy_impl.cpp
index fc5098d1f1..961eb9ae0d 100644
--- a/src/tex2lyx/dummy_impl.cpp
+++ b/src/tex2lyx/dummy_impl.cpp
@@ -38,8 +38,7 @@ namespace lyx {
 
 namespace frontend {
 namespace Alert {
-	void warning(docstring const & title, docstring const & message,
-				 bool const &)
+	void warning(docstring const & title, docstring const & message, bool)
 	{
 		cerr << to_utf8(title) << "\n" << to_utf8(message) << endl;
 	}
-- 
2.28.0.windows.1



More information about the lyx-devel mailing list