top | item 45403152

(no title)

age123456gpg | 5 months ago

  // hashItem computes the slot an item hashes to, given a total number of slots.
  func hashItem(item string, nslots uint64) uint64 {
    digest := md5.Sum([]byte(item))
    digestHigh := binary.BigEndian.Uint64(digest[8:16])
    digestLow := binary.BigEndian.Uint64(digest[:8])
    return (digestHigh | digestLow) % nslots
  }
Should be using XOR: (digestHigh ^ digestLow) % nslots

discuss

order

eliben|5 months ago

Thanks for spotting this, what a silly typo :)

... Fixed