Jeff King wrote:

>                                                              If we
> change the signature of align_ntohl, we can do this:
>
>   uint32_t align_ntohl(void *ptr)
>   {
>           uint32_t x;
>           memcpy(x, ptr, sizeof(x));
>           return ntohl(x);
>   }
>
>   ...
>
>   foo = align_ntohl(ptr);
>
> The memcpy solution is taken from read-cache.c, but as we noted, it
> probably hasn't been used a lot. The blk_sha1 get_be may be faster, as
> it converts as it reads.

I doubt there's much difference either way, especially after an
optimizer gets its hands on it.  According to [1] ARM has no fast
byte swap instruction so with -O0 the byte-at-a-time implementation is
probably faster there.  I can try a performance test if you like.

Jonathan

[1] http://thread.gmane.org/gmane.comp.version-control.git/125737
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to