lemire/javaewah — pull request #9 by mctofu (2012-02-09 21:25:12+00:00)
Title: instance reusability changes

Here's two commits, one to add the clear() method and one to reuse the existing buffer if possible in the deserialize method.

I added a basic test for the clear() method that covers some of the different code paths in the set method. This may need more review to make sure there isn't some case that won't work properly with a dirty buffer.

One other change I'm considering is with the serialization/deserialization process. My thought is that it isn't that important to preserve the actual buffer size. Especially since with this change it's more of a minimum buffer size rather than actual buffer size. In my use case the bitmap is considered read only after deserializing so creating a new buffer that is larger than actualsizeinwords is just overhead. Perhaps this might vary with other users. Anyway, my proposal would be to not include the buffer size when serializing and when deserializing use actualsizeinwords to determine the buffer size. This may be inconvenient for existing users with serialized bitmaps since this change would be incompatible with the old format.