[m-rev.] for review: reading multibyte integers from binary file streams

Julien Fischer jfischer at opturion.com
Wed Jan 9 13:19:39 AEDT 2019


On Wed, 9 Jan 2019, Zoltan Somogyi wrote:

>
> On Tue, 8 Jan 2019 04:02:56 +0000 (UTC), Julien Fischer <jfischer at opturion.com> wrote:
>>> I will have a look if you send me the diff as an attachment, though
>>> someone else should check the Java and C# versions.
>>
>> Attached.
>
> And the review is attached to this email.

Thanks Zoltan, I'll post a full response later, however this is one
point in your review that needs to be addresed before I do that.

> > +read_binary_int16_be(Result, !IO) :-
> > +    binary_input_stream(Stream, !IO),
> > +    read_binary_int16_be(Stream, Result, !IO).
> > +
> > +read_binary_int16_be(binary_input_stream(Stream), Result, !IO) :-
> > +    do_read_binary_uint16_le(Stream, Result0, UInt16LE, IncompleteBytes,
> > +        Error, !IO),
> > +    (
> > +        Result0 = ok,
> > +        UInt16BE = reverse_bytes(UInt16LE),
> > +        Int16 = cast_from_uint16(UInt16BE),
> > +        Result = ok(Int16)
> 
> Doing the conversion from byte sequence to an N bit int one way, then
> reversing the bytes in the N bit int, is slower than building the N bit int
> the right way in the first place. It does require fewer lines of code.
> Is that your reason for choosing this approach?

Yes, specifically it reduces the amount of foreign code required.  Do
you (or anyone else for that matter) want to avoid the byte reversal?

Julien.


More information about the reviews mailing list