github.com/zhangdapeng520/zdpgo_json@v0.1.5/reflect2/go_above_118.go (about)

     1  //go:build go1.18
     2  // +build go1.18
     3  
     4  package reflect2
     5  
     6  import (
     7  	"unsafe"
     8  )
     9  
    10  // m escapes into the return value, but the caller of mapiterinit
    11  // doesn't let the return value escape.
    12  //go:noescape
    13  //go:linkname mapiterinit reflect.mapiterinit
    14  func mapiterinit(rtype unsafe.Pointer, m unsafe.Pointer, it *hiter)
    15  
    16  func (type2 *UnsafeMapType) UnsafeIterate(obj unsafe.Pointer) MapIterator {
    17  	var it hiter
    18  	mapiterinit(type2.rtype, *(*unsafe.Pointer)(obj), &it)
    19  	return &UnsafeMapIterator{
    20  		hiter:      &it,
    21  		pKeyRType:  type2.pKeyRType,
    22  		pElemRType: type2.pElemRType,
    23  	}
    24  }