aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/json.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2024-02-20 09:37:50 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2024-02-20 16:01:40 +0200
commit6ff1cf35f78a24d52603d84eac9349b3d4670c6c (patch)
tree3c549345e303b25617b70e96800f8d1fbb7a9595 /libbuild2/json.cxx
parentc2d2a1ac0ac41a068c4bf09f8236a61d576e74f5 (diff)
Make json value type prepend non-overriding for consistency with map
Diffstat (limited to 'libbuild2/json.cxx')
-rw-r--r--libbuild2/json.cxx16
1 files changed, 8 insertions, 8 deletions
diff --git a/libbuild2/json.cxx b/libbuild2/json.cxx
index 6295b59..4ed1631 100644
--- a/libbuild2/json.cxx
+++ b/libbuild2/json.cxx
@@ -511,7 +511,7 @@ namespace build2
}
void json_value::
- append (json_value&& v)
+ append (json_value&& v, bool override)
{
if (type == json_type::null)
{
@@ -584,10 +584,10 @@ namespace build2
{
return m.name == o.name;
}));
- if (i != object.end ())
- i->value = move (m.value);
- else
+ if (i == object.end ())
object.push_back (move (m));
+ else if (override)
+ i->value = move (m.value);
}
}
@@ -602,7 +602,7 @@ namespace build2
}
void json_value::
- prepend (json_value&& v)
+ prepend (json_value&& v, bool override)
{
if (type == json_type::null)
{
@@ -675,10 +675,10 @@ namespace build2
{
return m.name == o.name;
}));
- if (i != object.end ())
- i->value = move (m.value);
- else
+ if (i == object.end ())
object.insert (object.begin (), move (m));
+ else if (override)
+ i->value = move (m.value);
}
}