[m-rev.] for review: faster int to decimal string conversion

Julien Fischer jfischer at opturion.com
Sun Oct 17 17:03:51 AEDT 2021


Hi Zoltan,

On Sun, 17 Oct 2021, Zoltan Somogyi wrote:

> 2021-10-17 16:44 GMT+11:00 "Julien Fischer" <jfischer at opturion.com>:
>> 3. Should I add the benchmarking code I used to the benchmarks?
>
> Yes.

Shall do.

>> -int_to_string(N) = S1 :-
>> -    int_to_string(N, S1).
>> +:- pragma foreign_proc("C",
>> +    int_to_string(I::in) = (S::uo),
>> +    [will_not_call_mercury, promise_pure, thread_safe, will_not_modify_trail],
>
> The C code looks good; I can't vouch for the C# and Java versions.
>
> The original code had the function version of int_to_string forward
> to the predicate version, which is what the library usually does.
> Your diff reverses this. Why?

*_to_string for the other integer types is a function, so for
consistency with them.  That said, none of other integer types
has a predicate version.

I'm happy to swap it back, if that's what you prefer.

On another matter, the signature for benchmark_det_io/7 is

    :- pred benchmark_det_io(pred(T1, T2, T3, T3), T1, T2, T3, T3, int,
     int).
    :- mode benchmark_det_io(pred(in, out, di, uo) is det, in, out, di, uo,
     in, out) is cc_multi.

Is there some reason we use the type variable T3 for the I/O state argument,
other than at the time the predicate benchmark_det_io was added, the benchmarking
module didn't import the io module?

Julien.


More information about the reviews mailing list