aboutsummaryrefslogtreecommitdiff
path: root/core/bytes
diff options
context:
space:
mode:
authorlaytan <laytanlaats@hotmail.com>2024-09-05 13:30:46 +0200
committerlaytan <laytanlaats@hotmail.com>2024-09-05 13:30:46 +0200
commita99e57c62c1c2d6b0e7a5fcd841eba79e9255d5b (patch)
tree1a8add787eb271c98967ad47a2e75854d74b8938 /core/bytes
parentddf5ca7adf16b87c202989537840d6099c553638 (diff)
bytes: fix last_index_byte off-by-one
Diffstat (limited to 'core/bytes')
-rw-r--r--core/bytes/bytes.odin8
1 files changed, 3 insertions, 5 deletions
diff --git a/core/bytes/bytes.odin b/core/bytes/bytes.odin
index 5a510951e..45eb44307 100644
--- a/core/bytes/bytes.odin
+++ b/core/bytes/bytes.odin
@@ -476,11 +476,9 @@ last_index_byte :: proc(s: []byte, c: byte) -> int #no_bounds_check {
// worth vectorizing assuming there is a hardware vector unit, and
// the data size is large enough.
if i < SIMD_REG_SIZE_128 {
- if i > 0 { // Handle s == nil.
- for /**/; i >= 0; i -= 1 {
- if s[i] == c {
- return i
- }
+ #reverse for ch, j in s {
+ if ch == c {
+ return j
}
}
return -1