@@ -947,9 +947,10 @@ func (v Value) MapKeys() []Value {
947
947
k := New (v .typecode .Key ())
948
948
e := New (v .typecode .Elem ())
949
949
950
+ typecode := (* mapType )(unsafe .Pointer ((v .typecode .underlying ())))
950
951
keyType := v .typecode .key ()
951
952
keyTypeIsEmptyInterface := keyType .Kind () == Interface && keyType .NumMethod () == 0
952
- shouldUnpackInterface := ! keyTypeIsEmptyInterface && keyType .Kind () != String && ! keyType . isBinary ()
953
+ shouldUnpackInterface := ! keyTypeIsEmptyInterface && keyType .Kind () != String && ! typecode . isBinaryKey ()
953
954
954
955
for hashmapNext (v .pointer (), it , k .value , e .value ) {
955
956
if shouldUnpackInterface {
@@ -979,6 +980,7 @@ func (v Value) MapIndex(key Value) Value {
979
980
panic (& ValueError {Method : "MapIndex" , Kind : v .Kind ()})
980
981
}
981
982
983
+ typecode := (* mapType )(unsafe .Pointer (v .typecode .underlying ()))
982
984
vkey := v .typecode .key ()
983
985
984
986
// compare key type with actual key type of map
@@ -997,7 +999,7 @@ func (v Value) MapIndex(key Value) Value {
997
999
return Value {}
998
1000
}
999
1001
return elem .Elem ()
1000
- } else if vkey . isBinary () {
1002
+ } else if typecode . isBinaryKey () {
1001
1003
var keyptr unsafe.Pointer
1002
1004
if key .isIndirect () || key .typecode .Size () > unsafe .Sizeof (uintptr (0 )) {
1003
1005
keyptr = key .value
@@ -1028,10 +1030,11 @@ func (v Value) MapRange() *MapIter {
1028
1030
panic (& ValueError {Method : "MapRange" , Kind : v .Kind ()})
1029
1031
}
1030
1032
1033
+ typecode := (* mapType )(unsafe .Pointer (v .typecode .underlying ()))
1031
1034
keyType := v .typecode .key ()
1032
1035
1033
1036
keyTypeIsEmptyInterface := keyType .Kind () == Interface && keyType .NumMethod () == 0
1034
- shouldUnpackInterface := ! keyTypeIsEmptyInterface && keyType .Kind () != String && ! keyType . isBinary ()
1037
+ shouldUnpackInterface := ! keyTypeIsEmptyInterface && keyType .Kind () != String && ! typecode . isBinaryKey ()
1035
1038
1036
1039
return & MapIter {
1037
1040
m : v ,
@@ -1824,6 +1827,7 @@ func (v Value) SetMapIndex(key, elem Value) {
1824
1827
}
1825
1828
1826
1829
vkey := v .typecode .key ()
1830
+ typecode := (* mapType )(unsafe .Pointer (v .typecode .underlying ()))
1827
1831
1828
1832
// compare key type with actual key type of map
1829
1833
if ! key .typecode .AssignableTo (vkey ) {
@@ -1859,7 +1863,7 @@ func (v Value) SetMapIndex(key, elem Value) {
1859
1863
hashmapStringSet (v .pointer (), * (* string )(key .value ), elemptr )
1860
1864
}
1861
1865
1862
- } else if key . typecode .isBinary () {
1866
+ } else if typecode .isBinaryKey () {
1863
1867
var keyptr unsafe.Pointer
1864
1868
if key .isIndirect () || key .typecode .Size () > unsafe .Sizeof (uintptr (0 )) {
1865
1869
keyptr = key .value
@@ -1965,14 +1969,15 @@ func MakeMapWithSize(typ Type, n int) Value {
1965
1969
panic ("reflect.MakeMapWithSize: negative size hint" )
1966
1970
}
1967
1971
1968
- key := typ .Key ().(* rawType )
1969
- val := typ .Elem ().(* rawType )
1972
+ typecode := (* mapType )(unsafe .Pointer (typ .(* rawType ).underlying ()))
1973
+ key := typecode .rawType .key ()
1974
+ val := typecode .rawType .elem ()
1970
1975
1971
1976
var alg uint8
1972
1977
1973
1978
if key .Kind () == String {
1974
1979
alg = hashmapAlgorithmString
1975
- } else if key . isBinary () {
1980
+ } else if typecode . isBinaryKey () {
1976
1981
alg = hashmapAlgorithmBinary
1977
1982
} else {
1978
1983
alg = hashmapAlgorithmInterface
0 commit comments