hare

[hare] The Hare programming language
git clone https://git.torresjrjr.com/hare.git
Log | Files | Refs | README | LICENSE

commit fd269b13cae1b1a972877b8ca48ef351aaa63bed
parent 7ec19f2d2fa87255654d0239ec8d3e446c48797d
Author: Sebastian <sebastian@sebsite.pw>
Date:   Mon, 27 Nov 2023 01:18:16 -0500

bytes: replace if expressions with logical and

Signed-off-by: Sebastian <sebastian@sebsite.pw>

Diffstat:
Mbytes/contains.ha | 7+++----
1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/bytes/contains.ha b/bytes/contains.ha @@ -19,8 +19,7 @@ export fn contains(haystack: []u8, needles: (u8 | []u8)...) bool = { // Returns true if "in" has the given prefix, false otherwise export fn hasprefix(in: []u8, prefix: []u8) bool = { - return if (len(in) < len(prefix)) false - else equal(in[..len(prefix)], prefix); + return len(in) >= len(prefix) && equal(in[..len(prefix)], prefix); }; @test fn hasprefix() void = { @@ -44,8 +43,8 @@ export fn hasprefix(in: []u8, prefix: []u8) bool = { // Returns true if "in" has the given suffix, false otherwise export fn hassuffix(in: []u8, suffix: []u8) bool = { - return if (len(in) < len(suffix)) false - else equal(in[len(in) - len(suffix)..], suffix); + return len(in) >= len(suffix) + && equal(in[len(in) - len(suffix)..], suffix); }; @test fn hassuffix() void = {