willf/bitset — pull request #14 by lemire (2014-02-11 16:13:39+00:00)
Title: Optimization + inplace operations

Points to consider:

1) I have added inplace operations. These can be very useful, as they can avoid an unnecessary copy. For fun, consider the case where you have two bloom filters, but you want to merge them. A simple in-place union would be best.

2) I suggest being conservative about modifying the object. For example, when calling "Equal", it is kind of surprising that the calling object would be modified. This could lead to evil bugs.

3) For the intersection, union... operations, you had a loop with an embedded if clause. I don't know if the compiler is smart enough to optimize this away. Maybe. Maybe not. I have rewritten the code so that you don't have to rely on having a smart compiler.

4) I have modified the NextSet function is that it is more Go-ish. I don't know whether it is better, faster... I did not benchmark it, but it feels nicer to me.

5) Though I have not fixed it, I think that there is a deeper design issue. My understanding is that we access slices/arrays using an int type index in Go. Slice lengths are similarly int-valued. So you are doing a lot of messing around with uints, but this is not necessary, I think.