Use Json::StaticString for field names

Clean up some code relating to unknown fields and avoid
allocate/copy/free cycles for Json objects containing
serialized field names.
This commit is contained in:
JoelKatz
2018-08-07 13:30:52 -07:00
committed by Nik Bougalis
parent 8c1123edc6
commit b6363289bf
4 changed files with 44 additions and 49 deletions

View File

@@ -141,16 +141,12 @@ std::string STArray::getText () const
Json::Value STArray::getJson (int p) const
{
Json::Value v = Json::arrayValue;
int index = 1;
for (auto const& object: v_)
{
if (object.getSType () != STI_NOTPRESENT)
{
Json::Value& inner = v.append (Json::objectValue);
auto const& fname = object.getFName ();
auto k = fname.hasName () ? fname.fieldName : std::to_string(index);
inner[k] = object.getJson (p);
index++;
inner [object.getFName().getJsonName()] = object.getJson (p);
}
}
return v;