Merge pull request #6324 from Faker-09/dynamic_array_move_assert

Small optimization for dynamic arrays
This commit is contained in:
gingerBill
2026-02-24 08:11:34 +00:00
committed by GitHub
3 changed files with 7 additions and 7 deletions

View File

@@ -893,8 +893,8 @@ _reserve_dynamic_array :: #force_no_inline proc(a: ^Raw_Dynamic_Array, size_of_e
if a.allocator.procedure == nil {
a.allocator = context.allocator
assert(a.allocator.procedure != nil)
}
assert(a.allocator.procedure != nil)
old_size := a.cap * size_of_elem
new_size := capacity * size_of_elem
@@ -953,8 +953,8 @@ _resize_dynamic_array :: #force_no_inline proc(a: ^Raw_Dynamic_Array, size_of_el
if a.allocator.procedure == nil {
a.allocator = context.allocator
assert(a.allocator.procedure != nil)
}
assert(a.allocator.procedure != nil)
old_size := a.cap * size_of_elem
new_size := length * size_of_elem
@@ -1023,8 +1023,8 @@ _shrink_dynamic_array :: proc(a: ^Raw_Dynamic_Array, size_of_elem, align_of_elem
if a.allocator.procedure == nil {
a.allocator = context.allocator
assert(a.allocator.procedure != nil)
}
assert(a.allocator.procedure != nil)
old_size := a.cap * size_of_elem
new_size := new_cap * size_of_elem

View File

@@ -105,8 +105,8 @@ make_soa_aligned :: proc($T: typeid/#soa[]$E, #any_int length, alignment: int, a
allocator := allocator
if allocator.procedure == nil {
allocator = context.allocator
assert(allocator.procedure != nil)
}
assert(allocator.procedure != nil)
new_bytes: []byte
new_bytes, err = allocator.procedure(
@@ -240,8 +240,8 @@ _reserve_soa :: proc(array: ^$T/#soa[dynamic]$E, capacity: int, zero_memory: boo
if array.allocator.procedure == nil {
array.allocator = context.allocator
assert(array.allocator.procedure != nil)
}
assert(array.allocator.procedure != nil)
footer := raw_soa_footer(array)
if size_of(E) == 0 {

View File

@@ -18,8 +18,8 @@ __dynamic_array_reserve :: proc(array_: rawptr, elem_size, elem_align: int, cap:
// assuming that appending/reserving will set the allocator, if it is not already set.
if array.allocator.procedure == nil {
array.allocator = context.allocator
assert(array.allocator.procedure != nil)
}
assert(array.allocator.procedure != nil)
if cap <= array.cap {
return true
@@ -52,8 +52,8 @@ __dynamic_array_shrink :: proc(array_: rawptr, elem_size, elem_align: int, new_c
// assuming that appending/reserving will set the allocator, if it is not already set.
if array.allocator.procedure == nil {
array.allocator = context.allocator
assert(array.allocator.procedure != nil)
}
assert(array.allocator.procedure != nil)
if new_cap > array.cap {
return