mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
builtin: apply .nogrow
flags to gcboehm array (#16689)
This commit is contained in:
parent
14cc43b0f6
commit
f0a252d0e6
@ -66,6 +66,9 @@ fn (mut a array) ensure_cap_noscan(required int) {
|
|||||||
if required <= a.cap {
|
if required <= a.cap {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if a.flags.has(.nogrow) {
|
||||||
|
panic('array.ensure_cap_noscan: array with the flag `.nogrow` cannot grow in size, array required new size: ${required}')
|
||||||
|
}
|
||||||
mut cap := if a.cap > 0 { a.cap } else { 2 }
|
mut cap := if a.cap > 0 { a.cap } else { 2 }
|
||||||
for required > cap {
|
for required > cap {
|
||||||
cap *= 2
|
cap *= 2
|
||||||
|
Loading…
Reference in New Issue
Block a user