[m-rev.] for review: Make string.left and string.right not create unused substrings.
Peter Wang
novalazy at gmail.com
Wed Oct 23 15:02:10 AEDT 2019
---
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
More information about the reviews
mailing list