24 Jan
2015
24 Jan
'15
4:09 p.m.
This approach - as shown - does have a drawback. If you have an array of 802511 32 bit lsb integers in the file, and the native int is 32 bit lsb, one read of 802511*4 bytes is vastly superior in performance to a loop that would read 4 bytes and call read_32_lsb on the byte[4]. Which is why the above is generally combined with
void read_32_lsb_n( int * first, int * last, FILE * fp );
It occurs to me that the library could benefit from similar additions to little_to_native et al, which are currently scalar-only and would, therefore, depend on a Sufficiently Smart(tm) compiler to optimize out the empty calls. Batch endianness fixups are very common and very performance sensitive.