From 6ff1cf35f78a24d52603d84eac9349b3d4670c6c Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 20 Feb 2024 09:37:50 +0200 Subject: Make json value type prepend non-overriding for consistency with map --- libbuild2/json.cxx | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'libbuild2/json.cxx') 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); } } -- cgit v1.1