Bug 1600963 - don't lookup keys twice in the serialized JSON; r=mccr8

Depends on D55687

Differential Revision: https://phabricator.services.mozilla.com/D55688

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Nathan Froyd 2019-12-03 17:52:40 +00:00
parent feb4f82205
commit 03bf239fb9

View File

@ -169,9 +169,12 @@ static nsTArray<typename T::KeyVal> GetJSONKeys(const Json::Value* aInput) {
field.valueWasSerialized = false;
field.key = static_cast<typename T::SerializableKeys>(i);
const std::string key = std::to_string(field.key);
if (aInput->isMember(key) && (*aInput)[key].isString()) {
field.value.Append(nsDependentCString((*aInput)[key].asCString()));
field.valueWasSerialized = true;
if (aInput->isMember(key)) {
const Json::Value& val = (*aInput)[key];
if (val.isString()) {
field.value.Append(nsDependentCString(val.asCString()));
field.valueWasSerialized = true;
}
}
fields.AppendElement(field);
}