mirror of
https://github.com/bblanchon/ArduinoJson.git
synced 2025-07-18 04:52:22 +02:00
Optimized size of JsonObjectBase indexer (-58 bytes)
This commit is contained in:
@ -39,17 +39,22 @@ size_t JsonObjectBase::printTo(Print& p) const
|
|||||||
|
|
||||||
JsonValue& JsonObjectBase::operator[](char const* key)
|
JsonValue& JsonObjectBase::operator[](char const* key)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < count; ++i)
|
KeyValuePair* p = items;
|
||||||
|
|
||||||
|
for (int i = count; i > 0; --i)
|
||||||
{
|
{
|
||||||
if (!strcmp(items[i].key, key))
|
bool keyMatches = strcmp(p->key, key) == 0;
|
||||||
{
|
|
||||||
return items[i].value;
|
if (keyMatches)
|
||||||
}
|
return p->value;
|
||||||
|
|
||||||
|
p++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count >= capacity)
|
if (count >= capacity)
|
||||||
return JsonValue::null();
|
return JsonValue::null();
|
||||||
|
|
||||||
items[count].key = key;
|
count++;
|
||||||
return items[count++].value;
|
p->key = key;
|
||||||
|
return p->value;
|
||||||
}
|
}
|
Reference in New Issue
Block a user