package runtime
import (
"internal/abi"
"internal/runtime/maps"
"internal/runtime/sys"
"unsafe"
)
const (
loadFactorNum = 7
loadFactorDen = 8
)
type maptype = abi .SwissMapType
var maps_errNilAssign error = plainError ("assignment to entry in nil map" )
func maps_mapKeyError(t *abi .SwissMapType , p unsafe .Pointer ) error {
return mapKeyError (t , p )
}
func makemap64(t *abi .SwissMapType , hint int64 , m *maps .Map ) *maps .Map {
if int64 (int (hint )) != hint {
hint = 0
}
return makemap (t , int (hint ), m )
}
func makemap_small() *maps .Map {
return maps .NewEmptyMap ()
}
func makemap(t *abi .SwissMapType , hint int , m *maps .Map ) *maps .Map {
if hint < 0 {
hint = 0
}
return maps .NewMap (t , uintptr (hint ), m , maxAlloc )
}
func mapaccess1(t *abi .SwissMapType , m *maps .Map , key unsafe .Pointer ) unsafe .Pointer
func mapaccess2(t *abi .SwissMapType , m *maps .Map , key unsafe .Pointer ) (unsafe .Pointer , bool )
func mapaccess1_fat(t *abi .SwissMapType , m *maps .Map , key , zero unsafe .Pointer ) unsafe .Pointer {
e := mapaccess1 (t , m , key )
if e == unsafe .Pointer (&zeroVal [0 ]) {
return zero
}
return e
}
func mapaccess2_fat(t *abi .SwissMapType , m *maps .Map , key , zero unsafe .Pointer ) (unsafe .Pointer , bool ) {
e := mapaccess1 (t , m , key )
if e == unsafe .Pointer (&zeroVal [0 ]) {
return zero , false
}
return e , true
}
func mapassign(t *abi .SwissMapType , m *maps .Map , key unsafe .Pointer ) unsafe .Pointer
func mapdelete(t *abi .SwissMapType , m *maps .Map , key unsafe .Pointer ) {
if raceenabled && m != nil {
callerpc := sys .GetCallerPC ()
pc := abi .FuncPCABIInternal (mapdelete )
racewritepc (unsafe .Pointer (m ), callerpc , pc )
raceReadObjectPC (t .Key , key , callerpc , pc )
}
if msanenabled && m != nil {
msanread (key , t .Key .Size_ )
}
if asanenabled && m != nil {
asanread (key , t .Key .Size_ )
}
m .Delete (t , key )
}
func mapiterinit(t *abi .SwissMapType , m *maps .Map , it *maps .Iter ) {
if raceenabled && m != nil {
callerpc := sys .GetCallerPC ()
racereadpc (unsafe .Pointer (m ), callerpc , abi .FuncPCABIInternal (mapiterinit ))
}
it .Init (t , m )
it .Next ()
}
func mapiternext(it *maps .Iter ) {
if raceenabled {
callerpc := sys .GetCallerPC ()
racereadpc (unsafe .Pointer (it .Map ()), callerpc , abi .FuncPCABIInternal (mapiternext ))
}
it .Next ()
}
func mapclear(t *abi .SwissMapType , m *maps .Map ) {
if raceenabled && m != nil {
callerpc := sys .GetCallerPC ()
pc := abi .FuncPCABIInternal (mapclear )
racewritepc (unsafe .Pointer (m ), callerpc , pc )
}
m .Clear (t )
}
func reflect_makemap(t *abi .SwissMapType , cap int ) *maps .Map {
if t .Key .Equal == nil {
throw ("runtime.reflect_makemap: unsupported map key type" )
}
return makemap (t , cap , nil )
}
func reflect_mapaccess(t *abi .SwissMapType , m *maps .Map , key unsafe .Pointer ) unsafe .Pointer {
elem , ok := mapaccess2 (t , m , key )
if !ok {
elem = nil
}
return elem
}
func reflect_mapaccess_faststr(t *abi .SwissMapType , m *maps .Map , key string ) unsafe .Pointer {
elem , ok := mapaccess2_faststr (t , m , key )
if !ok {
elem = nil
}
return elem
}
func reflect_mapassign(t *abi .SwissMapType , m *maps .Map , key unsafe .Pointer , elem unsafe .Pointer ) {
p := mapassign (t , m , key )
typedmemmove (t .Elem , p , elem )
}
func reflect_mapassign_faststr(t *abi .SwissMapType , m *maps .Map , key string , elem unsafe .Pointer ) {
p := mapassign_faststr (t , m , key )
typedmemmove (t .Elem , p , elem )
}
func reflect_mapdelete(t *abi .SwissMapType , m *maps .Map , key unsafe .Pointer ) {
mapdelete (t , m , key )
}
func reflect_mapdelete_faststr(t *abi .SwissMapType , m *maps .Map , key string ) {
mapdelete_faststr (t , m , key )
}
func reflect_mapiterinit(t *abi .SwissMapType , m *maps .Map , it *maps .Iter ) {
mapiterinit (t , m , it )
}
func reflect_mapiternext(it *maps .Iter ) {
mapiternext (it )
}
func reflect_mapiterkey(it *maps .Iter ) unsafe .Pointer {
return it .Key ()
}
func reflect_mapiterelem(it *maps .Iter ) unsafe .Pointer {
return it .Elem ()
}
func reflect_maplen(m *maps .Map ) int {
if m == nil {
return 0
}
if raceenabled {
callerpc := sys .GetCallerPC ()
racereadpc (unsafe .Pointer (m ), callerpc , abi .FuncPCABIInternal (reflect_maplen ))
}
return int (m .Used ())
}
func reflect_mapclear(t *abi .SwissMapType , m *maps .Map ) {
mapclear (t , m )
}
func reflectlite_maplen(m *maps .Map ) int {
if m == nil {
return 0
}
if raceenabled {
callerpc := sys .GetCallerPC ()
racereadpc (unsafe .Pointer (m ), callerpc , abi .FuncPCABIInternal (reflect_maplen ))
}
return int (m .Used ())
}
func mapinitnoop()
func mapclone(m any ) any {
e := efaceOf (&m )
e .data = unsafe .Pointer (mapclone2 ((*abi .SwissMapType )(unsafe .Pointer (e ._type )), (*maps .Map )(e .data )))
return m
}
func mapclone2(t *abi .SwissMapType , src *maps .Map ) *maps .Map {
dst := makemap (t , int (src .Used ()), nil )
var iter maps .Iter
iter .Init (t , src )
for iter .Next (); iter .Key () != nil ; iter .Next () {
dst .Put (t , iter .Key (), iter .Elem ())
}
return dst
}
func keys(m any , p unsafe .Pointer ) {
panic ("unimplemented" )
}
func values(m any , p unsafe .Pointer ) {
panic ("unimplemented" )
}
The pages are generated with Golds v0.7.3-preview . (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu .
PR and bug reports are welcome and can be submitted to the issue list .
Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds .