» Sunday, 8 February A.D. 2009

git code snippet

I ran across this little snippet while reading through Git source code the other night:

	cnt = (len < 4) ? len : 4;
	len -= cnt;
	do {
		acc = (acc << 8) | (acc >> 24);
		*dst++ = acc;
	} while (--cnt);

What does the code do? It deposts a value consisting of CNT bytes, left justified in ACC, into the byte buffer DST in big-endian format. Clever, huh?

posted by Nate @ 1:24PM