Util: Optimize Value member away
This commit is contained in:
@@ -16,9 +16,8 @@
|
||||
|
||||
namespace Json {
|
||||
|
||||
Serializer::Serializer(const Value& value, const uint32_t indent, const char indentCharacter)
|
||||
: m_value(value)
|
||||
, m_indent(indent)
|
||||
Serializer::Serializer(const uint32_t indent, const char indentCharacter)
|
||||
: m_indent(indent)
|
||||
, m_indentCharacter(indentCharacter)
|
||||
{
|
||||
}
|
||||
@@ -29,9 +28,9 @@ Serializer::~Serializer()
|
||||
|
||||
// ------------------------------------------
|
||||
|
||||
std::string Serializer::dump()
|
||||
std::string Serializer::dump(const Value& value)
|
||||
{
|
||||
return dumpHelper(m_value);
|
||||
return dumpHelper(value);
|
||||
}
|
||||
|
||||
// ------------------------------------------
|
||||
|
||||
@@ -16,18 +16,16 @@ namespace Json {
|
||||
|
||||
class Serializer {
|
||||
public:
|
||||
Serializer(const Value& value, const uint32_t indent = 0, const char indentCharacter = ' ');
|
||||
Serializer(const uint32_t indent = 0, const char indentCharacter = ' ');
|
||||
virtual ~Serializer();
|
||||
|
||||
std::string dump();
|
||||
std::string dump(const Value& value);
|
||||
|
||||
private:
|
||||
std::string dumpHelper(const Value& value, const uint32_t indentLevel = 0);
|
||||
std::string dumpArray(const Value& value, const uint32_t indentLevel = 0);
|
||||
std::string dumpObject(const Value& value, const uint32_t indentLevel = 0);
|
||||
|
||||
Value m_value;
|
||||
|
||||
uint32_t m_indent { 0 };
|
||||
char m_indentCharacter { ' ' };
|
||||
};
|
||||
|
||||
@@ -159,8 +159,8 @@ Value Value::parse(const std::string& input)
|
||||
|
||||
std::string Value::dump(const uint32_t indent, const char indentCharacter) const
|
||||
{
|
||||
Serializer serializer(*this, indent, indentCharacter);
|
||||
return serializer.dump();
|
||||
Serializer serializer(indent, indentCharacter);
|
||||
return serializer.dump(*this);
|
||||
}
|
||||
|
||||
void Value::emplace_back(Value value)
|
||||
|
||||
Reference in New Issue
Block a user