AK: Simplify JsonObject and JsonArray API a little bit

Instead of set(const JsonValue&) and set(JsonValue&&), just do
set(JsonValue) and let callers move() if they want. This removes some
ambiguity and the compiler is smart enough to optimize it anyway.
This commit is contained in:
Andreas Kling 2020-03-06 08:49:48 +01:00
parent 211e938234
commit dc039fdc7e
Notes: sideshowbarker 2024-07-19 08:53:13 +09:00
2 changed files with 2 additions and 8 deletions

View file

@ -68,8 +68,7 @@ public:
const JsonValue& operator[](int index) const { return at(index); }
void clear() { m_values.clear(); }
void append(const JsonValue& value) { m_values.append(value); }
void append(JsonValue&& value) { m_values.append(move(value)); }
void append(JsonValue value) { m_values.append(move(value)); }
template<typename Builder>
typename Builder::OutputType serialized() const;

View file

@ -85,16 +85,11 @@ public:
return m_members.contains(key);
}
void set(const String& key, JsonValue&& value)
void set(const String& key, JsonValue value)
{
m_members.set(key, move(value));
}
void set(const String& key, const JsonValue& value)
{
m_members.set(key, JsonValue(value));
}
template<typename Callback>
void for_each_member(Callback callback) const
{