diff options
author | Arne H Juul <arnej@yahoo-inc.com> | 2017-02-21 10:24:40 +0100 |
---|---|---|
committer | Arne H Juul <arnej@yahoo-inc.com> | 2017-02-21 10:24:40 +0100 |
commit | 126268b4dc5ca5bff75f9c254a134a5ca50e601c (patch) | |
tree | 269a552daea62dc3200ea549ca7c3695f4cd7d4f /vsm/src/vespa | |
parent | a7b95060654eee88b8ec80f536174b72e73e3d20 (diff) |
use range-based for loops
Diffstat (limited to 'vsm/src/vespa')
-rw-r--r-- | vsm/src/vespa/vsm/vsm/slimefieldwriter.cpp | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/vsm/src/vespa/vsm/vsm/slimefieldwriter.cpp b/vsm/src/vespa/vsm/vsm/slimefieldwriter.cpp index 728e756b622..2d53e4d3fa4 100644 --- a/vsm/src/vespa/vsm/vsm/slimefieldwriter.cpp +++ b/vsm/src/vespa/vsm/vsm/slimefieldwriter.cpp @@ -54,12 +54,12 @@ SlimeFieldWriter::traverseRecursive(const document::FieldValue & fv, Cursor &a = inserter.insertArray(); Memory imem("item"); Memory wmem("weight"); - for (document::WeightedSetFieldValue::const_iterator itr = wsfv.begin(); itr != wsfv.end(); ++itr) { + for (const auto &entry : wsfv) { Cursor &o = a.addObject(); - const document::FieldValue & nfv = *itr->first; + const document::FieldValue & nfv = *entry.first; ObjectInserter oi(o, imem); traverseRecursive(nfv, oi); - int weight = static_cast<const document::IntFieldValue &>(*itr->second).getValue(); + int weight = static_cast<const document::IntFieldValue &>(*entry.second).getValue(); o.setLong(wmem, weight); } } else { @@ -69,33 +69,33 @@ SlimeFieldWriter::traverseRecursive(const document::FieldValue & fv, } else if (fv.getClass().inherits(document::MapFieldValue::classId)) { const document::MapFieldValue & mfv = static_cast<const document::MapFieldValue &>(fv); + const document::MapDataType& mapType = static_cast<const document::MapDataType &>(*mfv.getDataType()); Cursor &a = inserter.insertArray(); Memory keymem("key"); Memory valmem("value"); - for (document::MapFieldValue::const_iterator itr = mfv.begin(); itr != mfv.end(); ++itr) { + for (const auto &entry : mfv) { Cursor &o = a.addObject(); ObjectInserter ki(o, keymem); - traverseRecursive(*itr->first, ki); - const document::MapDataType& mapType = static_cast<const document::MapDataType &>(*mfv.getDataType()); + traverseRecursive(*entry.first, ki); document::FieldPathEntry valueEntry( mapType, mapType.getKeyType(), mapType.getValueType(), false, true); _currPath.push_back(valueEntry); ObjectInserter vi(o, valmem); - traverseRecursive(*itr->second, vi); + traverseRecursive(*entry.second, vi); _currPath.pop_back(); } } else if (fv.getClass().inherits(document::StructuredFieldValue::classId)) { const document::StructuredFieldValue & sfv = static_cast<const document::StructuredFieldValue &>(fv); Cursor &o = inserter.insertObject(); - for (document::StructuredFieldValue::const_iterator itr = sfv.begin(); itr != sfv.end(); ++itr) { + for (const document::Field & entry : sfv) { // TODO: Why do we have to iterate like this? - document::FieldPathEntry fi(sfv.getField(itr.field().getName())); + document::FieldPathEntry fi(sfv.getField(entry.getName())); _currPath.push_back(fi); if (explorePath()) { - Memory keymem(itr.field().getName()); + Memory keymem(entry.getName()); ObjectInserter oi(o, keymem); - document::FieldValue::UP fval(sfv.getValue(itr.field())); + document::FieldValue::UP fval(sfv.getValue(entry)); traverseRecursive(*fval, oi); } _currPath.pop_back(); |