migrate to new mutable decl syntax
This commit is contained in:
@@ -17,7 +17,7 @@ init proc($T type, allocator mem.Allocator) ArrayList(T) {
|
||||
}
|
||||
|
||||
deinit proc($T type, list @mut ArrayList(T)) void {
|
||||
allocation []mut T :: list.items.ptr[..list.capacity]
|
||||
allocation :: list.items.ptr[..list.capacity]
|
||||
mem.free(list.allocator, allocation)
|
||||
list.items = mem.empty(T)
|
||||
list.capacity = 0
|
||||
@@ -28,9 +28,9 @@ hide reserve proc($T type, list @mut ArrayList(T), min_capacity usize) void ! me
|
||||
return
|
||||
}
|
||||
|
||||
new_capacity usize = 8
|
||||
new_capacity := 8
|
||||
if list.capacity >= 8 {
|
||||
half usize :: divtrunc!(list.capacity, 2)
|
||||
half :: divtrunc!(list.capacity, 2)
|
||||
if list.capacity > maxval!(usize) - half {
|
||||
new_capacity = min_capacity
|
||||
} else {
|
||||
|
||||
@@ -2,7 +2,7 @@ import "@std/mem"
|
||||
import "@std/testing"
|
||||
|
||||
handles_append test {
|
||||
list ArrayList(i32) = init(mem.c_allocator)
|
||||
list ArrayList(i32) := init(mem.c_allocator)
|
||||
defer deinit(&list)
|
||||
|
||||
try append(&list, 42)
|
||||
@@ -12,7 +12,7 @@ handles_append test {
|
||||
}
|
||||
|
||||
handles_clear test {
|
||||
list ArrayList(i32) = init(mem.c_allocator)
|
||||
list ArrayList(i32) := init(mem.c_allocator)
|
||||
defer deinit(&list)
|
||||
|
||||
try append(&list, 42)
|
||||
@@ -22,7 +22,7 @@ handles_clear test {
|
||||
}
|
||||
|
||||
handles_reserve test {
|
||||
list ArrayList(i32) = init(mem.c_allocator)
|
||||
list ArrayList(i32) := init(mem.c_allocator)
|
||||
defer deinit(&list)
|
||||
|
||||
try reserve(&list, 10)
|
||||
|
||||
Reference in New Issue
Block a user