Redmine #6214: Fix memory alignment errors when using LMDB/NextDB().

This was causing SPARC architecture to crash when expecting a struct
in the value, since the struct would be aligned to a byte position
which depended on the length of the key. x86 is also slower when
accessing unaligned data types, so should be an improvement there as
well.
Modulo and division by powers of two is optimised to shifts. I've no problem which version to keep, but for me the modulo one is much clearer.