Reduced size by 2 bytes

This commit is contained in:
Benoit Blanchon
2014-11-08 21:37:02 +01:00
parent 36ee4876c6
commit 12e374d0da

View File

@ -29,16 +29,19 @@ const JsonVariant &JsonObject::at(const char *key) const {
} }
JsonVariant &JsonObject::operator[](const char *key) { JsonVariant &JsonObject::operator[](const char *key) {
node_type *existingNode = getNodeAt(key); // try to find an existing node
if (existingNode) return existingNode->content.value; node_type *node = getNodeAt(key);
node_type *newNode = createNode(); // not fount => create a new one
if (!newNode) return JsonVariant::invalid(); if (!node) {
node = createNode();
if (!node) return JsonVariant::invalid();
newNode->content.key = key; node->content.key = key;
addNode(newNode); addNode(node);
}
return newNode->content.value; return node->content.value;
} }
void JsonObject::remove(char const *key) { removeNode(getNodeAt(key)); } void JsonObject::remove(char const *key) { removeNode(getNodeAt(key)); }