package maps
import (
)
func ( *abi.SwissMapType, unsafe.Pointer) error
var errNilAssign error
var zeroVal [abi.ZeroValSize]byte
func ( *abi.SwissMapType, *Map, unsafe.Pointer) unsafe.Pointer {
if race.Enabled && != nil {
:= sys.GetCallerPC()
:= abi.FuncPCABIInternal()
race.ReadPC(unsafe.Pointer(), , )
race.ReadObjectPC(.Key, , , )
}
if msan.Enabled && != nil {
msan.Read(, .Key.Size_)
}
if asan.Enabled && != nil {
asan.Read(, .Key.Size_)
}
if == nil || .Used() == 0 {
if := mapKeyError(, ); != nil {
panic()
}
return unsafe.Pointer(&zeroVal[0])
}
if .writing != 0 {
fatal("concurrent map read and map write")
}
:= .Hasher(, .seed)
if .dirLen <= 0 {
, , := .getWithKeySmall(, , )
if ! {
return unsafe.Pointer(&zeroVal[0])
}
return
}
:= .directoryIndex()
:= .directoryAt()
:= makeProbeSeq(h1(), .groups.lengthMask)
for ; ; = .next() {
:= .groups.group(, .offset)
:= .ctrls().matchH2(h2())
for != 0 {
:= .first()
:= .key(, )
:=
if .IndirectKey() {
= *((*unsafe.Pointer)())
}
if .Key.Equal(, ) {
:= unsafe.Pointer(uintptr() + .ElemOff)
if .IndirectElem() {
= *((*unsafe.Pointer)())
}
return
}
= .removeFirst()
}
= .ctrls().matchEmpty()
if != 0 {
return unsafe.Pointer(&zeroVal[0])
}
}
}
func ( *abi.SwissMapType, *Map, unsafe.Pointer) (unsafe.Pointer, bool) {
if race.Enabled && != nil {
:= sys.GetCallerPC()
:= abi.FuncPCABIInternal(runtime_mapaccess1)
race.ReadPC(unsafe.Pointer(), , )
race.ReadObjectPC(.Key, , , )
}
if msan.Enabled && != nil {
msan.Read(, .Key.Size_)
}
if asan.Enabled && != nil {
asan.Read(, .Key.Size_)
}
if == nil || .Used() == 0 {
if := mapKeyError(, ); != nil {
panic()
}
return unsafe.Pointer(&zeroVal[0]), false
}
if .writing != 0 {
fatal("concurrent map read and map write")
}
:= .Hasher(, .seed)
if .dirLen == 0 {
, , := .getWithKeySmall(, , )
if ! {
return unsafe.Pointer(&zeroVal[0]), false
}
return , true
}
:= .directoryIndex()
:= .directoryAt()
:= makeProbeSeq(h1(), .groups.lengthMask)
for ; ; = .next() {
:= .groups.group(, .offset)
:= .ctrls().matchH2(h2())
for != 0 {
:= .first()
:= .key(, )
:=
if .IndirectKey() {
= *((*unsafe.Pointer)())
}
if .Key.Equal(, ) {
:= unsafe.Pointer(uintptr() + .ElemOff)
if .IndirectElem() {
= *((*unsafe.Pointer)())
}
return , true
}
= .removeFirst()
}
= .ctrls().matchEmpty()
if != 0 {
return unsafe.Pointer(&zeroVal[0]), false
}
}
}
func ( *abi.SwissMapType, *Map, unsafe.Pointer) unsafe.Pointer {
if == nil {
panic(errNilAssign)
}
if race.Enabled {
:= sys.GetCallerPC()
:= abi.FuncPCABIInternal()
race.WritePC(unsafe.Pointer(), , )
race.ReadObjectPC(.Key, , , )
}
if msan.Enabled {
msan.Read(, .Key.Size_)
}
if asan.Enabled {
asan.Read(, .Key.Size_)
}
if .writing != 0 {
fatal("concurrent map writes")
}
:= .Hasher(, .seed)
.writing ^= 1
if .dirPtr == nil {
.growToSmall()
}
if .dirLen == 0 {
if .used < abi.SwissMapGroupSlots {
:= .putSlotSmall(, , )
if .writing == 0 {
fatal("concurrent map writes")
}
.writing ^= 1
return
}
.growToTable()
}
var unsafe.Pointer
:
for {
:= .directoryIndex()
:= .directoryAt()
:= makeProbeSeq(h1(), .groups.lengthMask)
var groupReference
var uintptr
for ; ; = .next() {
:= .groups.group(, .offset)
:= .ctrls().matchH2(h2())
for != 0 {
:= .first()
:= .key(, )
:=
if .IndirectKey() {
= *((*unsafe.Pointer)())
}
if .Key.Equal(, ) {
if .NeedKeyUpdate() {
typedmemmove(.Key, , )
}
= unsafe.Pointer(uintptr() + .ElemOff)
if .IndirectElem() {
= *((*unsafe.Pointer)())
}
.checkInvariants(, )
break
}
= .removeFirst()
}
= .ctrls().matchEmpty()
if != 0 {
var uintptr
if .data != nil {
=
=
.growthLeft++
} else {
= .first()
}
if .growthLeft > 0 {
:= .key(, )
:=
if .IndirectKey() {
:= newobject(.Key)
*(*unsafe.Pointer)() =
=
}
typedmemmove(.Key, , )
= unsafe.Pointer(uintptr() + .ElemOff)
if .IndirectElem() {
:= newobject(.Elem)
*(*unsafe.Pointer)() =
=
}
.ctrls().set(, ctrl(h2()))
.growthLeft--
.used++
.used++
.checkInvariants(, )
break
}
.rehash(, )
continue
}
if .data == nil {
= .ctrls().matchEmptyOrDeleted()
if != 0 {
=
= .first()
}
}
}
}
if .writing == 0 {
fatal("concurrent map writes")
}
.writing ^= 1
return
}