diff options
author | Jose <jose@zeroc.com> | 2019-03-27 11:22:47 +0100 |
---|---|---|
committer | Jose <jose@zeroc.com> | 2019-03-27 11:22:47 +0100 |
commit | b530de3bd83c1a6226dabcb347874c2b7357eb88 (patch) | |
tree | bf227f371d50c6b89be8acde1c2862a72f8ff7c3 /cpp/src/slice2swift/Gen.cpp | |
parent | Fix for readPendingValues (diff) | |
download | ice-b530de3bd83c1a6226dabcb347874c2b7357eb88.tar.bz2 ice-b530de3bd83c1a6226dabcb347874c2b7357eb88.tar.xz ice-b530de3bd83c1a6226dabcb347874c2b7357eb88.zip |
Dictionary unmarshal improvements
Diffstat (limited to 'cpp/src/slice2swift/Gen.cpp')
-rw-r--r-- | cpp/src/slice2swift/Gen.cpp | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/cpp/src/slice2swift/Gen.cpp b/cpp/src/slice2swift/Gen.cpp index dc86dfdf638..301d709364f 100644 --- a/cpp/src/slice2swift/Gen.cpp +++ b/cpp/src/slice2swift/Gen.cpp @@ -651,23 +651,20 @@ Gen::TypesVisitor::visitDictionary(const DictionaryPtr& p) out << nl << "var v = " << name << "()"; if(isClassType(p->valueType())) { - out << nl << "var entries = [DictionaryEntryReference<" << keyType << ", " << valueType << ">]()"; - out << nl << "for _ in 0 ..< sz"; + out << nl << "let e = Ice.DictEntryArray<" << keyType << ", " << valueType << ">(size: sz)"; + out << nl << "for i in 0 ..< sz"; out << sb; string keyParam = "let key: " + keyType; writeMarshalUnmarshalCode(out, p->keyType(), p, keyParam, false); out << nl << "v[key] = nil as " << valueType; - out << nl << "let ref = DictionaryEntryReference("; - out.useCurrentPosAsIndent(); - out << "key: key," << nl; - out << "value: UnsafeMutablePointer<" << valueType << ">(&v[key, default:nil]))"; - out.restoreIndent(); - out << nl << "entries.append(ref)"; - writeMarshalUnmarshalCode(out, p->valueType(), p, "ref.value.pointee", false); + out << nl << "e.values[i] = Ice.DictEntry<" << keyType << ", " << valueType << ">(" + << "key: key, " + << "value: UnsafeMutablePointer<" << valueType << ">(&v[key, default:nil]))"; + writeMarshalUnmarshalCode(out, p->valueType(), p, "e.values[i].value.pointee", false); out << eb; - out << nl << "for entry in entries" << sb; - out << nl << "entry.value = UnsafeMutablePointer<" << valueType << ">(&v[entry.key, default:nil])"; + out << nl << "for i in 0..<sz" << sb; + out << nl << "e.values[i].value = UnsafeMutablePointer<" << valueType << ">(&v[e.values[i].key, default:nil])"; out << eb; } else |