[m-rev.] for review: Avoid memory allocation for common string to int conversions.

Peter Wang novalazy at gmail.com
Mon Jun 20 16:13:45 AEST 2016


On Mon, 20 Jun 2016 14:28:16 +1000 (AEST), Julien Fischer <jfischer at opturion.com> wrote:
> 
> Hi Peter,
> 
> On Mon, 20 Jun 2016, Peter Wang wrote:
> 
> > It might only be worth doing this for decimal and hexadecimal.
> > Octal and binary are not really very common.
> > ---
> >
> > library/string.m:
> > 	Make base_string_to_int pass a constant higher order term
> > 	to string.foldl_between for common bases 10, 16, 8, 2.
> 
> That looks fine.  I assume (at least at the default optimisation level)
> the compiler isn't specialising the foldl_between calls?  At least
> for the decimal case that may be worth looking at as well.

Ok, we can also get rid of the allocations by inlining foldl_between/6
and foldl_between_2/6, then enabling higher-order specialisation and
unused argument elimination.

It's seems rather finicky, and foldl_between expands to not a small
amount of code.  I will stick with the existing patch but add comment in
case any one wants to revisit it.

Peter


More information about the reviews mailing list