go icon indicating copy to clipboard operation
go copied to clipboard

Is hash function used for small struct's fields hash-conflict-free ?

Open AsterDY opened this issue 4 years ago • 0 comments

https://github.com/json-iterator/go/blob/master/iter_object.go#L49 This function use a simple hash func to calculate one token's hash value (int64) which then is directly used to match one struct field directly without string check. But what if hash conflict happens? ex: a field called "Field1" is supposed to match a token called "Field1", however one token called "FieldXX" (or anything else has the same hash value) can also be regarded as this field's matcher and parsed. Can this hash func avoid this case? If it does, please give some references to read about it

AsterDY avatar Feb 25 '21 05:02 AsterDY