mirror of
https://github.com/Ed94/Odin.git
synced 2026-07-26 01:13:48 +00:00
Use uint instead of int to improve code generation for bounds checking
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user