[m-rev.] for review: Reduce memory allocation in string.to_upper, string.to_lower.

Julien Fischer jfischer at opturion.com
Mon Jun 20 14:39:08 AEST 2016


On Mon, 20 Jun 2016, Peter Wang wrote:

> library/string.m:
> 	Implement to_upper(in, uo) and to_lower(in, uo) with foreign
> 	code, not creating intermediate character lists.

I guess we can't currently rely on the compiler not making string
constants unique, otherwise you could add the (di, uo) modes as well.

>
> 	Implement to_upper(in, in) and to_lower(in, in) modes without
> 	allocating memory.
>
> 	Be more specific in documentation about which characters are
> 	affected by some functions/predicates.


For consistency you should change the similar documentation in
parsing_utils as well.

> diff --git a/library/string.m b/library/string.m
> index 55ef8b3..c13f7d4 100644

...

> @@ -4574,10 +4574,56 @@ uncapitalize_first(S0, S) :-
>         S = S0
>     ).
> 
> +%---------------------%
> +
> to_upper(S1) = S2 :-
>     to_upper(S1, S2).
> 
> -to_upper(StrIn, StrOut) :-
> +:- pragma promise_pure(to_upper/2).

Is there a reason you used promise_pure rather than
promise_equivalent_clauses?

The rest looks fine.

Julien.


More information about the reviews mailing list