Skip to content

Commit

Permalink
gcs: optimize inner loop, take advantage that P is a power of two
Browse files Browse the repository at this point in the history
  • Loading branch information
Roasbeef committed Jun 9, 2017
1 parent 5e1eb02 commit 578a4e3
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions gcs_light_client.mediawiki
Expand Up @@ -340,11 +340,11 @@ gcs_compress(sorted_set, fp) -> []byte:
for value in sorted_set:
// Compute the difference between this value and the last value modulo
// P.
let remainder = (value - last_value) % P
let remainder = (value - last_value) & (P - 1)
// Compute the difference between this value and the last one, divided
// by P. This is our quotient.
let quotient = (value - last_value - remainder) / P
let quotient = (value - last_value - remainder) >> fp
// Write out the quotient value in unary into the bit stream.
unary_encode(stream, quotient)
Expand Down

0 comments on commit 578a4e3

Please sign in to comment.