read-cache.c: allow unaligned mapping of the index file
commitd60c49c2d7f683cd24a738533846cd3e34f2073e
authorJunio C Hamano <gitster@pobox.com>
Tue, 3 Apr 2012 22:53:10 +0000 (3 15:53 -0700)
committerJunio C Hamano <gitster@pobox.com>
Tue, 3 Apr 2012 23:24:45 +0000 (3 16:24 -0700)
tree21edaed27035f0878e78e5ed107b7c7f81dc3fa8
parentdb3b313c84522d89ac358187a7f6928dfcfb1e7d
read-cache.c: allow unaligned mapping of the index file

Both the on-disk format v2 and v3 pads the "name" field to the multiple of
eight to make sure that various quantities in network long/short type can
be accessed with ntohl/ntohs without having to worry about alignment, but
this forces us to waste disk I/O bandwidth.

Introduce ntoh_s()/ntoh_l() macros that the callers can use as if they were
the regular ntohs()/ntohl() on a field that may not be aligned correctly.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
read-cache.c