Skip to content

Commit 67bc939

Browse files
committed
Removed entirely unnecessary _copy_value API from web::json::details::_Value class.
1 parent 260e38c commit 67bc939

File tree

2 files changed

+3
-43
lines changed

2 files changed

+3
-43
lines changed

Release/include/cpprest/json.h

Lines changed: 1 addition & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1348,8 +1348,6 @@ namespace json
13481348
class _Value
13491349
{
13501350
public:
1351-
virtual std::unique_ptr<_Value> _copy_value() = 0;
1352-
13531351
virtual bool has_field(const utility::string_t &) const { return false; }
13541352
virtual value get_field(const utility::string_t &) const { throw json_exception(_XPLATSTR("not an object")); }
13551353
virtual value get_element(array::size_type) const { throw json_exception(_XPLATSTR("not an array")); }
@@ -1419,18 +1417,7 @@ namespace json
14191417
class _Null : public _Value
14201418
{
14211419
public:
1422-
1423-
virtual std::unique_ptr<_Value> _copy_value()
1424-
{
1425-
return utility::details::make_unique<_Null>();
1426-
}
1427-
14281420
virtual json::value::value_type type() const { return json::value::Null; }
1429-
1430-
_Null() { }
1431-
1432-
private:
1433-
template<typename CharType> friend class json::details::JSON_Parser;
14341421
};
14351422

14361423
class _Number : public _Value
@@ -1442,11 +1429,6 @@ namespace json
14421429
_Number(int64_t value) : m_number(value) { }
14431430
_Number(uint64_t value) : m_number(value) { }
14441431

1445-
virtual std::unique_ptr<_Value> _copy_value()
1446-
{
1447-
return utility::details::make_unique<_Number>(*this);
1448-
}
1449-
14501432
virtual json::value::value_type type() const { return json::value::Number; }
14511433

14521434
virtual bool is_integer() const { return m_number.is_integral(); }
@@ -1478,11 +1460,7 @@ namespace json
14781460
class _Boolean : public _Value
14791461
{
14801462
public:
1481-
1482-
virtual std::unique_ptr<_Value> _copy_value()
1483-
{
1484-
return utility::details::make_unique<_Boolean>(*this);
1485-
}
1463+
_Boolean(bool value) : m_value(value) { }
14861464

14871465
virtual json::value::value_type type() const { return json::value::Boolean; }
14881466

@@ -1502,9 +1480,6 @@ namespace json
15021480
#endif
15031481
private:
15041482
template<typename CharType> friend class json::details::JSON_Parser;
1505-
public:
1506-
_Boolean(bool value) : m_value(value) { }
1507-
private:
15081483
bool m_value;
15091484
};
15101485

@@ -1545,11 +1520,6 @@ namespace json
15451520
return *this;
15461521
}
15471522

1548-
virtual std::unique_ptr<_Value> _copy_value()
1549-
{
1550-
return utility::details::make_unique<_String>(*this);
1551-
}
1552-
15531523
virtual json::value::value_type type() const { return json::value::String; }
15541524

15551525
virtual const utility::string_t & as_string() const;
@@ -1627,11 +1597,6 @@ namespace json
16271597

16281598
virtual ~_Object() {}
16291599

1630-
virtual std::unique_ptr<_Value> _copy_value()
1631-
{
1632-
return utility::details::make_unique<_Object>(*this);
1633-
}
1634-
16351600
virtual json::object& as_object() { return m_object; }
16361601

16371602
virtual const json::object& as_object() const { return m_object; }
@@ -1740,11 +1705,6 @@ namespace json
17401705
_Array(array::size_type size) : m_array(size) {}
17411706
_Array(array::storage_type elements) : m_array(std::move(elements)) { }
17421707

1743-
virtual std::unique_ptr<_Value> _copy_value()
1744-
{
1745-
return utility::details::make_unique<_Array>(*this);
1746-
}
1747-
17481708
virtual json::value::value_type type() const { return json::value::Array; }
17491709

17501710
virtual json::array& as_array() { return m_array; }

Release/src/json/json.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ m_value(utility::details::make_unique<web::json::details::_String>(utility::stri
123123
{ }
124124

125125
web::json::value::value(const value &other) :
126-
m_value(other.m_value->_copy_value())
126+
m_value(other.m_value.get())
127127
#ifdef ENABLE_JSON_VALUE_VISUALIZER
128128
,m_kind(other.m_kind)
129129
#endif
@@ -133,7 +133,7 @@ web::json::value &web::json::value::operator=(const value &other)
133133
{
134134
if(this != &other)
135135
{
136-
m_value = std::unique_ptr<details::_Value>(other.m_value->_copy_value());
136+
m_value = std::unique_ptr<details::_Value>(other.m_value.get());
137137
#ifdef ENABLE_JSON_VALUE_VISUALIZER
138138
m_kind = other.m_kind;
139139
#endif

0 commit comments

Comments
 (0)