@ -947,9 +947,10 @@ func (v Value) MapKeys() []Value {
k := New ( v . typecode . Key ( ) )
e := New ( v . typecode . Elem ( ) )
typecode := ( * mapType ) ( unsafe . Pointer ( ( v . typecode . underlying ( ) ) ) )
keyType := v . typecode . key ( )
keyTypeIsEmptyInterface := keyType . Kind ( ) == Interface && keyType . NumMethod ( ) == 0
shouldUnpackInterface := ! keyTypeIsEmptyInterface && keyType . Kind ( ) != String && ! keyTyp e. isBinary ( )
shouldUnpackInterface := ! keyTypeIsEmptyInterface && keyType . Kind ( ) != String && ! typecod e. isBinaryKe y ( )
for hashmapNext ( v . pointer ( ) , it , k . value , e . value ) {
if shouldUnpackInterface {
@ -979,6 +980,7 @@ func (v Value) MapIndex(key Value) Value {
panic ( & ValueError { Method : "MapIndex" , Kind : v . Kind ( ) } )
}
typecode := ( * mapType ) ( unsafe . Pointer ( v . typecode . underlying ( ) ) )
vkey := v . typecode . key ( )
// compare key type with actual key type of map
@ -997,7 +999,7 @@ func (v Value) MapIndex(key Value) Value {
return Value { }
}
return elem . Elem ( )
} else if vkey . isBinary ( ) {
} else if typecode . isBinaryKe y ( ) {
var keyptr unsafe . Pointer
if key . isIndirect ( ) || key . typecode . Size ( ) > unsafe . Sizeof ( uintptr ( 0 ) ) {
keyptr = key . value
@ -1028,10 +1030,11 @@ func (v Value) MapRange() *MapIter {
panic ( & ValueError { Method : "MapRange" , Kind : v . Kind ( ) } )
}
typecode := ( * mapType ) ( unsafe . Pointer ( v . typecode . underlying ( ) ) )
keyType := v . typecode . key ( )
keyTypeIsEmptyInterface := keyType . Kind ( ) == Interface && keyType . NumMethod ( ) == 0
shouldUnpackInterface := ! keyTypeIsEmptyInterface && keyType . Kind ( ) != String && ! keyTyp e. isBinary ( )
shouldUnpackInterface := ! keyTypeIsEmptyInterface && keyType . Kind ( ) != String && ! typecod e. isBinaryKe y ( )
return & MapIter {
m : v ,
@ -1824,6 +1827,7 @@ func (v Value) SetMapIndex(key, elem Value) {
}
vkey := v . typecode . key ( )
typecode := ( * mapType ) ( unsafe . Pointer ( v . typecode . underlying ( ) ) )
// compare key type with actual key type of map
if ! key . typecode . AssignableTo ( vkey ) {
@ -1859,7 +1863,7 @@ func (v Value) SetMapIndex(key, elem Value) {
hashmapStringSet ( v . pointer ( ) , * ( * string ) ( key . value ) , elemptr )
}
} else if key . typecode . isBinary ( ) {
} else if typecode . isBinaryKe y ( ) {
var keyptr unsafe . Pointer
if key . isIndirect ( ) || key . typecode . Size ( ) > unsafe . Sizeof ( uintptr ( 0 ) ) {
keyptr = key . value
@ -1965,14 +1969,15 @@ func MakeMapWithSize(typ Type, n int) Value {
panic ( "reflect.MakeMapWithSize: negative size hint" )
}
key := typ . Key ( ) . ( * rawType )
val := typ . Elem ( ) . ( * rawType )
typecode := ( * mapType ) ( unsafe . Pointer ( typ . ( * rawType ) . underlying ( ) ) )
key := typecode . rawType . key ( )
val := typecode . rawType . elem ( )
var alg uint8
if key . Kind ( ) == String {
alg = hashmapAlgorithmString
} else if key . isBinary ( ) {
} else if typecode . isBinaryKe y ( ) {
alg = hashmapAlgorithmBinary
} else {
alg = hashmapAlgorithmInterface