[luatex] fio library byte order

Taco Hoekwater taco at elvenkind.com
Mon Jun 29 10:30:14 CEST 2020



> On 28 Jun 2020, at 03:26, Reinhard Kotucha <reinhard.kotucha at web.de> wrote:
> 
>>> 
>>> As far as I understand it's sufficient that the relevant
>>> functions read{cardinal,integer}{2,4} obey a flag which tells
>>> them whether byte re-ordering is necessary.  The flag has to be
>>> set if host and file byte orders are different.  I don't know
>>> whether we have to consider 64 bit integers too.
>> 
>> that adds passing parameters and checking them for each call
>> ... you can then as well use lua's 'read' function and convert with
>> string.byte/char which is then about equally fast
> 
> This is what I actually did.  It took 14 s to process a PNM file, way
> too much if I have to process hundreds or thousands files.  I ported
> the script to C and could process the file within 270 ms.  I can't
> imagine that obeying a variable in C can slow down everything so much.

The quick way to fix this without noticeable overhead would be to add
a few extra function definitions for read{cardinal,integer}{2,4} in
the byte permutations that are likely to actually happen. There are 
not *that* many of those.

Taco






More information about the luatex mailing list.