mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-17 19:23:25 +00:00
runtime: make arrays and struct field hashes order dependent
This commit is contained in:
committed by
Damian Gryski
parent
7a9c649268
commit
c4219439eb
@@ -807,13 +807,13 @@ func hashmapInterfaceHash(itf interface{}, seed uintptr) uint32 {
|
|||||||
case reflectlite.Array:
|
case reflectlite.Array:
|
||||||
var hash uint32
|
var hash uint32
|
||||||
for i := 0; i < x.Len(); i++ {
|
for i := 0; i < x.Len(); i++ {
|
||||||
hash ^= hashmapInterfaceHash(valueInterfaceUnsafe(x.Index(i)), seed)
|
hash = (hash * 31) ^ hashmapInterfaceHash(valueInterfaceUnsafe(x.Index(i)), seed)
|
||||||
}
|
}
|
||||||
return hash
|
return hash
|
||||||
case reflectlite.Struct:
|
case reflectlite.Struct:
|
||||||
var hash uint32
|
var hash uint32
|
||||||
for i := 0; i < x.NumField(); i++ {
|
for i := 0; i < x.NumField(); i++ {
|
||||||
hash ^= hashmapInterfaceHash(valueInterfaceUnsafe(x.Field(i)), seed)
|
hash = (hash * 31) ^ hashmapInterfaceHash(valueInterfaceUnsafe(x.Field(i)), seed)
|
||||||
}
|
}
|
||||||
return hash
|
return hash
|
||||||
default:
|
default:
|
||||||
|
|||||||
Reference in New Issue
Block a user