gcs: explicitly optimize inner loop of gcs filter computation

This commit is contained in:
Olaoluwa Osuntokun 2017-06-08 18:26:27 -07:00
parent c26776fe48
commit 18097a52c4

View file

@ -93,11 +93,11 @@ func BuildGCSFilter(P uint8, key [KeySize]byte, data [][]byte) (*Filter, error)
for _, v := range values { for _, v := range values {
// Calculate the difference between this value and the last, // Calculate the difference between this value and the last,
// modulo P. // modulo P.
remainder = (v - lastValue) % f.modulusP remainder = (v - lastValue) & (f.modulusP - 1)
// Calculate the difference between this value and the last, // Calculate the difference between this value and the last,
// divided by P. // divided by P.
value = (v - lastValue - remainder) / f.modulusP value = (v - lastValue - remainder) >> f.p
lastValue = v lastValue = v
// Write the P multiple into the bitstream in unary; the // Write the P multiple into the bitstream in unary; the