1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

pref,cgen: support -no-bounds-checking, instead of -d no_bounds_checking, and make it enable direct_array_access for all fns/methods.

This commit is contained in:
Delyan Angelov
2022-10-30 14:06:07 +02:00
parent 54b623743d
commit 9edb48571f
8 changed files with 59 additions and 43 deletions

View File

@@ -122,7 +122,7 @@ fn (a array) repeat_to_depth_noscan(count int, depth int) array {
// insert inserts a value in the array at index `i`
fn (mut a array) insert_noscan(i int, val voidptr) {
$if !no_bounds_checking ? {
$if !no_bounds_checking {
if i < 0 || i > a.len {
panic('array.insert: index out of range (i == $i, a.len == $a.len)')
}
@@ -138,7 +138,7 @@ fn (mut a array) insert_noscan(i int, val voidptr) {
// insert_many inserts many values into the array from index `i`.
[unsafe]
fn (mut a array) insert_many_noscan(i int, val voidptr, size int) {
$if !no_bounds_checking ? {
$if !no_bounds_checking {
if i < 0 || i > a.len {
panic('array.insert_many: index out of range (i == $i, a.len == $a.len)')
}
@@ -167,7 +167,7 @@ fn (mut a array) prepend_many_noscan(val voidptr, size int) {
// pop returns the last element of the array, and removes it.
fn (mut a array) pop_noscan() voidptr {
// in a sense, this is the opposite of `a << x`
$if !no_bounds_checking ? {
$if !no_bounds_checking {
if a.len == 0 {
panic('array.pop: array is empty')
}