1
0
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:
l-m 2022-12-16 16:57:50 +11:00 committed by GitHub
parent 14cc43b0f6
commit f0a252d0e6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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