|
@@ -691,6 +691,10 @@ type unsafeMapHashIter struct {
|
|
|
// it unsafe.Pointer
|
|
// it unsafe.Pointer
|
|
|
// }
|
|
// }
|
|
|
|
|
|
|
|
|
|
+type mapIter struct {
|
|
|
|
|
+ unsafeMapIter
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
type unsafeMapIter struct {
|
|
type unsafeMapIter struct {
|
|
|
it *unsafeMapHashIter
|
|
it *unsafeMapHashIter
|
|
|
// k, v reflect.Value
|
|
// k, v reflect.Value
|
|
@@ -699,7 +703,7 @@ type unsafeMapIter struct {
|
|
|
kisref, visref bool
|
|
kisref, visref bool
|
|
|
mapvalues bool
|
|
mapvalues bool
|
|
|
done bool
|
|
done bool
|
|
|
-
|
|
|
|
|
|
|
+ started bool
|
|
|
// _ [2]uint64 // padding (cache-aligned)
|
|
// _ [2]uint64 // padding (cache-aligned)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -721,11 +725,12 @@ func (t *unsafeMapIter) Next() (r bool) {
|
|
|
if t == nil || t.done {
|
|
if t == nil || t.done {
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
- if t.it == nil {
|
|
|
|
|
- t.it = (*unsafeMapHashIter)(mapiterinit(t.mtyp, t.mptr))
|
|
|
|
|
- } else {
|
|
|
|
|
|
|
+ if t.started {
|
|
|
mapiternext((unsafe.Pointer)(t.it))
|
|
mapiternext((unsafe.Pointer)(t.it))
|
|
|
|
|
+ } else {
|
|
|
|
|
+ t.started = true
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
t.done = t.it.key == nil
|
|
t.done = t.it.key == nil
|
|
|
if t.done {
|
|
if t.done {
|
|
|
return
|
|
return
|
|
@@ -771,17 +776,20 @@ func unsafeMapKVPtr(urv *unsafeReflectValue) unsafe.Pointer {
|
|
|
return urv.ptr
|
|
return urv.ptr
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-func mapRange(m, k, v reflect.Value, mapvalues bool) (t *unsafeMapIter) {
|
|
|
|
|
|
|
+func mapRange(t *mapIter, m, k, v reflect.Value, mapvalues bool) {
|
|
|
if rvIsNil(m) {
|
|
if rvIsNil(m) {
|
|
|
// return &unsafeMapIter{done: true}
|
|
// return &unsafeMapIter{done: true}
|
|
|
|
|
+ t.done = true
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
|
|
+ t.done = false
|
|
|
|
|
+ t.started = false
|
|
|
// if unsafeMapIterUsePool {
|
|
// if unsafeMapIterUsePool {
|
|
|
// t = unsafeMapIterPool.Get().(*unsafeMapIter)
|
|
// t = unsafeMapIterPool.Get().(*unsafeMapIter)
|
|
|
// } else {
|
|
// } else {
|
|
|
// t = new(unsafeMapIter)
|
|
// t = new(unsafeMapIter)
|
|
|
// }
|
|
// }
|
|
|
- t = new(unsafeMapIter)
|
|
|
|
|
|
|
+ // t = new(unsafeMapIter)
|
|
|
// t.k = k
|
|
// t.k = k
|
|
|
// t.v = v
|
|
// t.v = v
|
|
|
t.mapvalues = mapvalues
|
|
t.mapvalues = mapvalues
|
|
@@ -792,6 +800,8 @@ func mapRange(m, k, v reflect.Value, mapvalues bool) (t *unsafeMapIter) {
|
|
|
t.mtyp = urv.typ
|
|
t.mtyp = urv.typ
|
|
|
t.mptr = rv2ptr(urv)
|
|
t.mptr = rv2ptr(urv)
|
|
|
|
|
|
|
|
|
|
+ t.it = (*unsafeMapHashIter)(mapiterinit(t.mtyp, t.mptr))
|
|
|
|
|
+
|
|
|
urv = (*unsafeReflectValue)(unsafe.Pointer(&k))
|
|
urv = (*unsafeReflectValue)(unsafe.Pointer(&k))
|
|
|
t.ktyp = urv.typ
|
|
t.ktyp = urv.typ
|
|
|
t.kptr = urv.ptr
|
|
t.kptr = urv.ptr
|
|
@@ -802,6 +812,9 @@ func mapRange(m, k, v reflect.Value, mapvalues bool) (t *unsafeMapIter) {
|
|
|
t.vtyp = urv.typ
|
|
t.vtyp = urv.typ
|
|
|
t.vptr = urv.ptr
|
|
t.vptr = urv.ptr
|
|
|
t.visref = refBitset.isset(byte(v.Kind()))
|
|
t.visref = refBitset.isset(byte(v.Kind()))
|
|
|
|
|
+ } else {
|
|
|
|
|
+ t.vtyp = nil
|
|
|
|
|
+ t.vptr = nil
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
return
|
|
return
|