[m-rev.] for review: Reduce memory allocation in string.to_upper, string.to_lower.
Peter Wang
novalazy at gmail.com
Mon Jun 20 17:31:48 AEST 2016
On Mon, 20 Jun 2016 14:39:08 +1000 (AEST), Julien Fischer <jfischer at opturion.com> wrote:
>
> 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.
>
Right.
> > 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.
Done.
> > 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?
Perhaps the error message should mention promise_equivalent_clauses;
I always forget it exists.
Thanks for the reviews.
Peter
More information about the reviews
mailing list