sharded.go
func djb33(seed uint32, k string) uint32 {
	var (
		l = uint32(len(k))
		d = 5381 + seed + l
		i = uint32(0)
	)
	// Why is all this 5x faster than a for loop?
	if l >= 4 {
		for i < l-4 {
			d = (d * 33) ^ uint32(k[i])
			d = (d * 33) ^ uint32(k[i+1])
			d = (d * 33) ^ uint32(k[i+2])
			d = (d * 33) ^ uint32(k[i+3])
			i += 4
		}
	}
	switch l - i {
	case 1:
	case 2:
		d = (d * 33) ^ uint32(k[i])
	case 3:
		d = (d * 33) ^ uint32(k[i])
		d = (d * 33) ^ uint32(k[i+1])
	case 4:
		d = (d * 33) ^ uint32(k[i])
		d = (d * 33) ^ uint32(k[i+1])
		d = (d * 33) ^ uint32(k[i+2])
	}
	return d ^ (d >> 16)
}
func djb33(seed uint32, k string) uint32 {
	var (
		l = uint32(len(k))
		d = 5381 + seed + l
		i = uint32(0)
	)
	// Why is all this 5x faster than a for loop?
	if l >= 4 {
		for i < l-4 {
			d = (d * 33) ^ uint32(k[i])
			d = (d * 33) ^ uint32(k[i+1])
			d = (d * 33) ^ uint32(k[i+2])
			d = (d * 33) ^ uint32(k[i+3])
			i += 4
		}
	}
	switch l - i {
	case 1:
	case 2:
		d = (d * 33) ^ uint32(k[i])
	case 3:
		d = (d * 33) ^ uint32(k[i])
		d = (d * 33) ^ uint32(k[i+1])
	case 4:
		d = (d * 33) ^ uint32(k[i])
		d = (d * 33) ^ uint32(k[i+1])
		d = (d * 33) ^ uint32(k[i+2])
	}
	return d ^ (d >> 16)
}
func djb33 ( seed uint32 , k string ) uint32 { var ( l = uint32 ( len ( k ) ) d = 5381 + seed + l i = uint32 ( 0 ) ) // Why is all this 5x faster than a for loop? if l >= 4 { for i < l - 4 { d = ( d * 33 ) ^ uint32 ( k [ i ] ) d = ( d * 33 ) ^ uint32 ( k [ i + 1 ] ) d = ( d * 33 ) ^ uint32 ( k [ i + 2 ] ) d = ( d * 33 ) ^ uint32 ( k [ i + 3 ] ) i += 4 } } switch l - i { case 1 : case 2 : d = ( d * 33 ) ^ uint32 ( k [ i ] ) case 3 : d = ( d * 33 ) ^ uint32 ( k [ i ] ) d = ( d * 33 ) ^ uint32 ( k [ i + 1 ] ) case 4 : d = ( d * 33 ) ^ uint32 ( k [ i ] ) d = ( d * 33 ) ^ uint32 ( k [ i + 1 ] ) d = ( d * 33 ) ^ uint32 ( k [ i + 2 ] ) } return d ^ ( d >> 16 ) }
// djb2 with better shuffling. 5x faster than FNV with the hash.Hash overhead.
djb2 with better shuffling . 5x faster than FNV with the hash . Hash overhead .