You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
i read soource code about interface hash table. the code say hash use Quadratic Probing. but absolutely not.
this is just h +=i not h +=i *i, this is a special design or a bug?
func (t *itabTableType) find(inter *interfacetype, typ *_type) *itab {
// Implemented using quadratic probing.
// Probe sequence is h(i) = h0 + i*(i+1)/2 mod 2^k.
// We're guaranteed to hit all table entries using this probe sequence.
mask := t.size - 1
h := itabHashFunc(inter, typ) & mask
for i := uintptr(1); ; i++ {
p := (**itab)(add(unsafe.Pointer(&t.entries), h*sys.PtrSize))
// Use atomic read here so if we see m != nil, we also see
// the initializations of the fields of m.
// m := *p
m := (*itab)(atomic.Loadp(unsafe.Pointer(p)))
if m == nil {
return nil
}
if m.inter == inter && m._type == typ {
return m
}
h += i
h &= mask
}
}
The text was updated successfully, but these errors were encountered:
h is increased on every iteration by an i that is increasing on every iteration. If it would be linear if the addition would be by a costant e.g. h += 10.
i read soource code about interface hash table. the code say hash use Quadratic Probing. but absolutely not.
this is just h +=i not h +=i *i, this is a special design or a bug?
The text was updated successfully, but these errors were encountered: