10Jan/09Off
Implementing xor in a bitunwise way
Bitunwise is one of my pet projects. It uses a common algorithm to reimplement memcpy, memset, memcmp, bzero, and kin. I decided to add support for xor'ing two byte streams. The first patch was small and easy to write, but it needed better abstraction. I took another look at the functions I was trying to implement and realized they can be grouped by number of input streams:
- zero input streams: bzero
- one input stream: memset, memcpy
- two input streams: xor
So now instead of calling into the core algorithm manually, the emitting functions call the appropriate arity helper method. It worked out to the same number of lines of code... BUT future emitting methods (e.g. nand) will be one or two liners.


