commit f953d88c886c39b5075bb271d564b2c9de0c68f9 Author: Yuriy Skalko <yuriy.ska...@gmail.com> Date: Thu Nov 19 13:24:04 2020 +0200
Simplify constructors --- src/Dimension.h | 28 +++++++++++----------------- src/graphics/PreviewLoader.cpp | 2 +- src/mathed/MathData.cpp | 3 +-- src/mathed/MathData.h | 15 ++++++++------- src/mathed/MathStream.cpp | 7 ++----- src/mathed/MathStream.h | 34 +++++++++++++++++----------------- 6 files changed, 40 insertions(+), 49 deletions(-) diff --git a/src/Dimension.h b/src/Dimension.h index 0f7fdab..802b3bb 100644 --- a/src/Dimension.h +++ b/src/Dimension.h @@ -18,16 +18,12 @@ namespace lyx { class Dimension { public: /// constructor - Dimension() : wid(0), asc(0), des(0) {} + Dimension() = default; /// initialize data Dimension(int w, int a, int d) : wid(w), asc(a), des(d) {} + /// + Dimension & operator=(Dimension const & dim) = default; - Dimension & operator=(Dimension const & dim) { - wid = dim.wid; - asc = dim.asc; - des = dim.des; - return *this; - } /// glue horizontally void operator+=(Dimension const & dim); /// set to empty box @@ -59,35 +55,33 @@ public: /// /// makes the code neither faster nor clearer /// width - int wid; + int wid = 0; /// ascent - int asc; + int asc = 0; /// descent - int des; + int des = 0; }; inline bool operator==(Dimension const & a, Dimension const & b) { - return a.wid == b.wid && a.asc == b.asc && a.des == b.des ; + return a.wid == b.wid && a.asc == b.asc && a.des == b.des; } inline bool operator!=(Dimension const & a, Dimension const & b) { - return a.wid != b.wid || a.asc != b.asc || a.des != b.des ; + return !(a == b); } class Point { public: - Point() - : x_(0), y_(0) - {} - + Point() = default; Point(int x, int y); - int x_, y_; + int x_ = 0; + int y_ = 0; }; } // namespace lyx diff --git a/src/graphics/PreviewLoader.cpp b/src/graphics/PreviewLoader.cpp index f9c0ba9..a7e37f3 100644 --- a/src/graphics/PreviewLoader.cpp +++ b/src/graphics/PreviewLoader.cpp @@ -631,7 +631,7 @@ void PreviewLoader::Impl::startLoading(bool wait) // Set \jobname of previews to the document name (see bug 9627) of << "\\def\\jobname{" - << from_utf8(changeExtension(buffer_.latexName(true), "")) + << from_utf8(changeExtension(buffer_.latexName(), "")) << "}\n"; LYXERR(Debug::LATEX, "Format = " << buffer_.params().getDefaultOutputFormat()); diff --git a/src/mathed/MathData.cpp b/src/mathed/MathData.cpp index 39d5f80..5372430 100644 --- a/src/mathed/MathData.cpp +++ b/src/mathed/MathData.cpp @@ -47,8 +47,7 @@ namespace lyx { MathData::MathData(Buffer * buf, const_iterator from, const_iterator to) - : base_type(from, to), minasc_(0), mindes_(0), slevel_(0), - sshift_(0), buffer_(buf) + : base_type(from, to), buffer_(buf) {} diff --git a/src/mathed/MathData.h b/src/mathed/MathData.h index 3474980..81d6cfc 100644 --- a/src/mathed/MathData.h +++ b/src/mathed/MathData.h @@ -68,8 +68,9 @@ public: public: /// - explicit MathData(Buffer * buf = 0) : minasc_(0), mindes_(0), slevel_(0), - sshift_(0), buffer_(buf) {} + MathData() = default; + /// + explicit MathData(Buffer * buf) : buffer_(buf) {} /// MathData(Buffer * buf, const_iterator from, const_iterator to); /// @@ -186,11 +187,11 @@ public: protected: /// cached values for super/subscript placement - mutable int minasc_; - mutable int mindes_; - mutable int slevel_; - mutable int sshift_; - Buffer * buffer_; + mutable int minasc_ = 0; + mutable int mindes_ = 0; + mutable int slevel_ = 0; + mutable int sshift_ = 0; + Buffer * buffer_ = nullptr; private: /// is this an exact match at this position? diff --git a/src/mathed/MathStream.cpp b/src/mathed/MathStream.cpp index 2f25ce6..588e219 100644 --- a/src/mathed/MathStream.cpp +++ b/src/mathed/MathStream.cpp @@ -126,11 +126,8 @@ WriteStream & operator<<(WriteStream & ws, docstring const & s) WriteStream::WriteStream(otexrowstream & os, bool fragile, bool latex, OutputType output, Encoding const * encoding) - : os_(os), fragile_(fragile), firstitem_(false), latex_(latex), - output_(output), pendingspace_(false), pendingbrace_(false), - textmode_(false), locked_(false), ascii_(false), canbreakline_(true), - mathsout_(false), ulemcmd_(NONE), line_(0), encoding_(encoding), - row_entry_(TexRow::row_none), mathclass_(false) + : os_(os), fragile_(fragile), latex_(latex), + output_(output), encoding_(encoding) {} diff --git a/src/mathed/MathStream.h b/src/mathed/MathStream.h index db4a499..94e810d 100644 --- a/src/mathed/MathStream.h +++ b/src/mathed/MathStream.h @@ -49,7 +49,7 @@ public: /// explicit WriteStream(otexrowstream & os, bool fragile = false, bool latex = false, OutputType output = wsDefault, - Encoding const * encoding = 0); + Encoding const * encoding = nullptr); /// ~WriteStream(); /// @@ -116,37 +116,37 @@ private: /// otexrowstream & os_; /// do we have to write \\protect sometimes - bool fragile_; + bool fragile_ = false; /// are we at the beginning of an MathData? - bool firstitem_; + bool firstitem_ = false; /// are we writing to .tex? - int latex_; + int latex_ = false; /// output type (default, source preview, instant preview)? - OutputType output_; + OutputType output_ = wsDefault; /// do we have a space pending? - bool pendingspace_; + bool pendingspace_ = false; /// do we have a brace pending? - bool pendingbrace_; + bool pendingbrace_ = false; /// are we in text mode when producing latex code? - bool textmode_; + bool textmode_ = false; /// are we allowed to switch mode when producing latex code? - bool locked_; + bool locked_ = false; /// should we use only ascii chars when producing latex code? - bool ascii_; + bool ascii_ = false; /// are we allowed to output an immediately following newline? - bool canbreakline_; + bool canbreakline_ = true; /// should we take care for striking out display math? - bool mathsout_; + bool mathsout_ = false; /// what ulem command are we inside (none, underline, strikeout)? - UlemCmdType ulemcmd_; + UlemCmdType ulemcmd_ = NONE; /// - int line_; + int line_ = 0; /// - Encoding const * encoding_; + Encoding const * encoding_ = nullptr; /// Row entry we are in - TexRow::RowEntry row_entry_; + TexRow::RowEntry row_entry_ = TexRow::row_none; /// whether we are in a MathClass inset - bool mathclass_; + bool mathclass_ = false; }; /// -- lyx-cvs mailing list lyx-cvs@lists.lyx.org http://lists.lyx.org/mailman/listinfo/lyx-cvs