mirror of
https://github.com/matrix-construct/construct
synced 2024-12-26 15:33:54 +01:00
ircd::json: Deeper copying on value copy ctor.
This commit is contained in:
parent
c2fbe50bce
commit
78d5825315
1 changed files with 8 additions and 8 deletions
16
ircd/json.cc
16
ircd/json.cc
|
@ -1210,19 +1210,19 @@ ircd::json::value::value(const value &other)
|
||||||
,alloc{other.alloc}
|
,alloc{other.alloc}
|
||||||
,floats{other.floats}
|
,floats{other.floats}
|
||||||
{
|
{
|
||||||
if(alloc && serial)
|
if(serial)
|
||||||
{
|
{
|
||||||
create_string(len, [this]
|
create_string(len, [&other]
|
||||||
(mutable_buffer &buffer)
|
(mutable_buffer &buffer)
|
||||||
{
|
{
|
||||||
consume(buffer, copy(buffer, string_view{*this}));
|
consume(buffer, copy(buffer, string_view{other}));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else switch(type)
|
else switch(type)
|
||||||
{
|
{
|
||||||
case OBJECT:
|
case OBJECT:
|
||||||
{
|
{
|
||||||
if(serial || !object)
|
if(!object)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
const size_t count(this->len);
|
const size_t count(this->len);
|
||||||
|
@ -1236,7 +1236,7 @@ ircd::json::value::value(const value &other)
|
||||||
|
|
||||||
case ARRAY:
|
case ARRAY:
|
||||||
{
|
{
|
||||||
if(serial || !array)
|
if(!array)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
const size_t count(this->len);
|
const size_t count(this->len);
|
||||||
|
@ -1250,13 +1250,13 @@ ircd::json::value::value(const value &other)
|
||||||
|
|
||||||
case STRING:
|
case STRING:
|
||||||
{
|
{
|
||||||
if(serial || !alloc || !string)
|
if(!string)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
create_string(serialized(*this), [this]
|
create_string(len, [&other]
|
||||||
(mutable_buffer &buffer)
|
(mutable_buffer &buffer)
|
||||||
{
|
{
|
||||||
json::stringify(buffer, *this);
|
copy(buffer, const_buffer{other.string, other.len});
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue