Use uint instead of int to improve code generation for bounds checking
This commit is contained in:
1 parent
35e70f4be1
commit
c4d19dfa92
5 files changed
+9
-12
No files matched your search
@@ -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