reflect: MapIter.Next() needs to allocate new keys/values every time

This commit is contained in:
Damian Gryski
2023-03-07 10:29:02 -08:00
committed by Ayke
parent 94a54bc105
commit ac36f232bc
+5 -4
View File
@@ -850,10 +850,8 @@ func (v Value) MapRange() *MapIter {
}
return &MapIter{
m: v,
it: hashmapNewIterator(),
key: New(v.typecode.Key()),
val: New(v.typecode.Elem()),
m: v,
it: hashmapNewIterator(),
}
}
@@ -883,6 +881,9 @@ func (it *MapIter) Value() Value {
}
func (it *MapIter) Next() bool {
it.key = New(it.m.typecode.Key())
it.val = New(it.m.typecode.Elem())
it.valid = hashmapNext(it.m.pointer(), it.it, it.key.value, it.val.value)
return it.valid
}