[m-rev.] for review: access bytes in bitmaps as uint8s
Julien Fischer
jfischer at opturion.com
Wed Jan 3 10:43:41 AEDT 2018
Hi Zoltan,
On Wed, 3 Jan 2018, Zoltan Somogyi wrote:
> On Sat, 30 Dec 2017 00:56:42 -0500 (EST), Julien Fischer <jfischer at opturion.com> wrote:
>> +get_uint8(BM, N) = U8 :-
>> + ( if N >= 0, in_range(BM, N * bits_per_byte + bits_per_byte - 1) then
>> + U8 = unsafe_get_uint8(BM, N)
>> + else
>> + throw_byte_bounds_error(BM, "bitmap.get_uint8", N)
>> + ).
>
> Shouldn't this call byte_in_range, instead of inlining it by hand?
> That would also avoid the double test of N >= 0.
>
> Same issue with set_uint8.
Done (and also for some of the existing code).
>> +:- pragma foreign_proc("Erlang",
>> + unsafe_get_uint8(BM::in, N::in) = (U8::out),
>> + [will_not_call_mercury, promise_pure, thread_safe],
>> +"
>> + {Bin, _} = BM,
>> + <<_:N/binary, U8/integer, _/binary>> = Bin
>> +").
>
> I don't understand this, or its set version.
I don't think it's worth going into further detail, since bit syntax
expressions are used a fair bit in the standard library (and are
documented in the Erlang refernce manual in any case).
Julien.
More information about the reviews
mailing list