diff --git a/include/json/value.h b/include/json/value.h index 3fdd884..71bc65c 100644 --- a/include/json/value.h +++ b/include/json/value.h @@ -54,7 +54,7 @@ namespace Json { */ class JSON_API Exception : public std::exception { public: - Exception(JSONCPP_STRING const& msg); + Exception(JSONCPP_STRING msg); ~Exception() JSONCPP_NOEXCEPT override; char const* what() const JSONCPP_NOEXCEPT override; diff --git a/include/json/writer.h b/include/json/writer.h index 7faaa02..34e71ed 100644 --- a/include/json/writer.h +++ b/include/json/writer.h @@ -300,8 +300,8 @@ public: /** * \param indentation Each level will be indented by this amount extra. */ - StyledStreamWriter(const JSONCPP_STRING& indentation = "\t"); - ~StyledStreamWriter() {} + StyledStreamWriter(JSONCPP_STRING indentation = "\t"); + ~StyledStreamWriter() = default; public: /** \brief Serialize a Value in JSON format. diff --git a/src/lib_json/json_reader.cpp b/src/lib_json/json_reader.cpp index ce4aac4..c5af014 100644 --- a/src/lib_json/json_reader.cpp +++ b/src/lib_json/json_reader.cpp @@ -88,9 +88,8 @@ bool Reader::containsNewLine(Reader::Location begin, Reader::Location end) { // ////////////////////////////////////////////////////////////////// Reader::Reader() - : errors_(), document_(), begin_(), end_(), current_(), lastValueEnd_(), - lastValue_(), commentsBefore_(), features_(Features::all()), - collectComments_() {} + : errors_(), document_(), commentsBefore_(), features_(Features::all()) + {} Reader::Reader(const Features& features) : errors_(), document_(), begin_(), end_(), current_(), lastValueEnd_(), diff --git a/src/lib_json/json_value.cpp b/src/lib_json/json_value.cpp index ef95117..2445d31 100644 --- a/src/lib_json/json_value.cpp +++ b/src/lib_json/json_value.cpp @@ -213,7 +213,7 @@ static inline void releaseStringValue(char* value, unsigned) { free(value); } namespace Json { -Exception::Exception(JSONCPP_STRING const& msg) : msg_(msg) {} +Exception::Exception(JSONCPP_STRING msg) : msg_(std::move(msg)) {} Exception::~Exception() JSONCPP_NOEXCEPT {} char const* Exception::what() const JSONCPP_NOEXCEPT { return msg_.c_str(); } RuntimeError::RuntimeError(JSONCPP_STRING const& msg) : Exception(msg) {} diff --git a/src/lib_json/json_writer.cpp b/src/lib_json/json_writer.cpp index 993001c..54fcb4f 100644 --- a/src/lib_json/json_writer.cpp +++ b/src/lib_json/json_writer.cpp @@ -642,8 +642,8 @@ bool StyledWriter::hasCommentForValue(const Value& value) { // Class StyledStreamWriter // ////////////////////////////////////////////////////////////////// -StyledStreamWriter::StyledStreamWriter(const JSONCPP_STRING& indentation) - : document_(nullptr), rightMargin_(74), indentation_(indentation), +StyledStreamWriter::StyledStreamWriter(JSONCPP_STRING indentation) + : document_(nullptr), indentation_(std::move(indentation)), addChildValues_(), indented_(false) {} void StyledStreamWriter::write(JSONCPP_OSTREAM& out, const Value& root) { @@ -872,11 +872,11 @@ struct CommentStyle { }; struct BuiltStyledStreamWriter : public StreamWriter { - BuiltStyledStreamWriter(JSONCPP_STRING const& indentation, + BuiltStyledStreamWriter(JSONCPP_STRING indentation, CommentStyle::Enum cs, - JSONCPP_STRING const& colonSymbol, - JSONCPP_STRING const& nullSymbol, - JSONCPP_STRING const& endingLineFeedSymbol, + JSONCPP_STRING colonSymbol, + JSONCPP_STRING nullSymbol, + JSONCPP_STRING endingLineFeedSymbol, bool useSpecialFloats, unsigned int precision, PrecisionType precisionType); @@ -912,17 +912,17 @@ private: PrecisionType precisionType_; }; BuiltStyledStreamWriter::BuiltStyledStreamWriter( - JSONCPP_STRING const& indentation, + JSONCPP_STRING indentation, CommentStyle::Enum cs, - JSONCPP_STRING const& colonSymbol, - JSONCPP_STRING const& nullSymbol, - JSONCPP_STRING const& endingLineFeedSymbol, + JSONCPP_STRING colonSymbol, + JSONCPP_STRING nullSymbol, + JSONCPP_STRING endingLineFeedSymbol, bool useSpecialFloats, unsigned int precision, PrecisionType precisionType) - : rightMargin_(74), indentation_(indentation), cs_(cs), - colonSymbol_(colonSymbol), nullSymbol_(nullSymbol), - endingLineFeedSymbol_(endingLineFeedSymbol), addChildValues_(false), + : rightMargin_(74), indentation_(std::move(indentation)), cs_(cs), + colonSymbol_(std::move(colonSymbol)), nullSymbol_(std::move(nullSymbol)), + endingLineFeedSymbol_(std::move(endingLineFeedSymbol)), addChildValues_(false), indented_(false), useSpecialFloats_(useSpecialFloats), precision_(precision), precisionType_(precisionType) {} int BuiltStyledStreamWriter::write(Value const& root, JSONCPP_OSTREAM* sout) {