[m-rev.] for review: Make string.left and string.right not create unused substrings.
Mark Brown
mark at mercurylang.org
Wed Oct 23 20:34:19 AEDT 2019
Did this have a log message? Otherwise fine.
On Wed, Oct 23, 2019 at 3:03 PM Peter Wang <novalazy at gmail.com> wrote:
>
> ---
> library/string.m | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/library/string.m b/library/string.m
> index 97b005841..4363c0c5f 100644
> --- a/library/string.m
> +++ b/library/string.m
> @@ -4171,7 +4171,7 @@ left(S1, N) = S2 :-
> left(S1, N, S2).
>
> left(String, Count, LeftString) :-
> - split(String, Count, LeftString, _RightString).
> + between(String, 0, Count, LeftString).
>
> left_by_codepoint(String, Count) = LeftString :-
> left_by_codepoint(String, Count, LeftString).
> @@ -4184,8 +4184,8 @@ right(S1, N) = S2 :-
>
> right(String, RightCount, RightString) :-
> length(String, Length),
> - LeftCount = Length - RightCount,
> - split(String, LeftCount, _LeftString, RightString).
> + Start = Length - RightCount,
> + between(String, Start, Length, RightString).
>
> right_by_codepoint(String, RightCount) = RightString :-
> right_by_codepoint(String, RightCount, RightString).
> --
> 2.23.0
>
> _______________________________________________
> reviews mailing list
> reviews at lists.mercurylang.org
> https://lists.mercurylang.org/listinfo/reviews
More information about the reviews
mailing list