@@ -6,7 +6,7 @@ package runtime
66// https://golang.org/src/runtime/map.go
77
88import (
9- "reflect "
9+ "internal/reflectlite "
1010 "tinygo"
1111 "unsafe"
1212)
@@ -539,8 +539,8 @@ func hashmapStringDelete(m *hashmap, key string) {
539539// a field is exported and thus allows circumventing the type system.
540540// The hash function needs it as it also needs to hash unexported struct fields.
541541//
542- //go:linkname valueInterfaceUnsafe reflect .valueInterfaceUnsafe
543- func valueInterfaceUnsafe (v reflect .Value ) interface {}
542+ //go:linkname valueInterfaceUnsafe internal/reflectlite .valueInterfaceUnsafe
543+ func valueInterfaceUnsafe (v reflectlite .Value ) interface {}
544544
545545func hashmapFloat32Hash (ptr unsafe.Pointer , seed uintptr ) uint32 {
546546 f := * (* uint32 )(ptr )
@@ -561,7 +561,7 @@ func hashmapFloat64Hash(ptr unsafe.Pointer, seed uintptr) uint32 {
561561}
562562
563563func hashmapInterfaceHash (itf interface {}, seed uintptr ) uint32 {
564- x := reflect .ValueOf (itf )
564+ x := reflectlite .ValueOf (itf )
565565 if x .RawType () == nil {
566566 return 0 // nil interface
567567 }
@@ -574,39 +574,39 @@ func hashmapInterfaceHash(itf interface{}, seed uintptr) uint32 {
574574 }
575575
576576 switch x .RawType ().Kind () {
577- case reflect .Int , reflect .Int8 , reflect .Int16 , reflect .Int32 , reflect .Int64 :
577+ case reflectlite .Int , reflectlite .Int8 , reflectlite .Int16 , reflectlite .Int32 , reflectlite .Int64 :
578578 return hash32 (ptr , x .RawType ().Size (), seed )
579- case reflect .Bool , reflect .Uint , reflect .Uint8 , reflect .Uint16 , reflect .Uint32 , reflect .Uint64 , reflect .Uintptr :
579+ case reflectlite .Bool , reflectlite .Uint , reflectlite .Uint8 , reflectlite .Uint16 , reflectlite .Uint32 , reflectlite .Uint64 , reflectlite .Uintptr :
580580 return hash32 (ptr , x .RawType ().Size (), seed )
581- case reflect .Float32 :
581+ case reflectlite .Float32 :
582582 // It should be possible to just has the contents. However, NaN != NaN
583583 // so if you're using lots of NaNs as map keys (you shouldn't) then hash
584584 // time may become exponential. To fix that, it would be better to
585585 // return a random number instead:
586586 // https://research.swtch.com/randhash
587587 return hashmapFloat32Hash (ptr , seed )
588- case reflect .Float64 :
588+ case reflectlite .Float64 :
589589 return hashmapFloat64Hash (ptr , seed )
590- case reflect .Complex64 :
590+ case reflectlite .Complex64 :
591591 rptr , iptr := ptr , unsafe .Add (ptr , 4 )
592592 return hashmapFloat32Hash (rptr , seed ) ^ hashmapFloat32Hash (iptr , seed )
593- case reflect .Complex128 :
593+ case reflectlite .Complex128 :
594594 rptr , iptr := ptr , unsafe .Add (ptr , 8 )
595595 return hashmapFloat64Hash (rptr , seed ) ^ hashmapFloat64Hash (iptr , seed )
596- case reflect .String :
596+ case reflectlite .String :
597597 return hashmapStringHash (x .String (), seed )
598- case reflect .Chan , reflect .Ptr , reflect .UnsafePointer :
598+ case reflectlite .Chan , reflectlite .Ptr , reflectlite .UnsafePointer :
599599 // It might seem better to just return the pointer, but that won't
600600 // result in an evenly distributed hashmap. Instead, hash the pointer
601601 // like most other types.
602602 return hash32 (ptr , x .RawType ().Size (), seed )
603- case reflect .Array :
603+ case reflectlite .Array :
604604 var hash uint32
605605 for i := 0 ; i < x .Len (); i ++ {
606606 hash ^= hashmapInterfaceHash (valueInterfaceUnsafe (x .Index (i )), seed )
607607 }
608608 return hash
609- case reflect .Struct :
609+ case reflectlite .Struct :
610610 var hash uint32
611611 for i := 0 ; i < x .NumField (); i ++ {
612612 hash ^= hashmapInterfaceHash (valueInterfaceUnsafe (x .Field (i )), seed )
0 commit comments