hare

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

commit 90ae641a44f3c08879c7bf43666bc8fd13aeeba8
parent 79a87fa3a6785f63402eae40f1518b944e676177
Author: Drew DeVault <sir@cmpwn.com>
Date:   Tue,  2 Mar 2021 15:06:02 -0500

bytes: simplify rindex

Diffstat:
Mbytes/index.ha | 6+++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/bytes/index.ha b/bytes/index.ha @@ -34,9 +34,9 @@ export fn rindex(haystack: []u8, needle: (u8 | []u8)) (size | void) = { }; fn rindex_byte(haystack: []u8, needle: u8) (size | void) = { - for (let i = 0z; i < len(haystack); i += 1) { - if (haystack[len(haystack) - i - 1] == needle) { - return len(haystack) - i - 1; + for (let i = len(haystack); i > 0; i -= 1) { + if (haystack[i - 1] == needle) { + return i - 1; }; }; };