aboutsummaryrefslogtreecommitdiff
path: root/core/slice
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2022-09-27 22:31:46 +0100
committergingerBill <bill@gingerbill.org>2022-09-27 22:31:46 +0100
commitc4d19dfa925ffe44c04fcda90543a272b7165274 (patch)
treec493697ab16154885febf04511f7f61e64b4bbbb /core/slice
parent35e70f4be17f4123ec25108d664864f13b38087e (diff)
Use `uint` instead of `int` to improve code generation for bounds checking
Diffstat (limited to 'core/slice')
-rw-r--r--core/slice/slice.odin4
1 files changed, 2 insertions, 2 deletions
diff --git a/core/slice/slice.odin b/core/slice/slice.odin
index abc84787f..032a8ca6e 100644
--- a/core/slice/slice.odin
+++ b/core/slice/slice.odin
@@ -321,14 +321,14 @@ last_ptr :: proc(array: $T/[]$E) -> ^E {
}
get :: proc(array: $T/[]$E, index: int) -> (value: E, ok: bool) {
- if 0 <= index && index < len(array) {
+ if uint(index) < len(array) {
value = array[index]
ok = true
}
return
}
get_ptr :: proc(array: $T/[]$E, index: int) -> (value: ^E, ok: bool) {
- if 0 <= index && index < len(array) {
+ if uint(index) < len(array) {
value = &array[index]
ok = true
}