Improve resize call

This commit is contained in:
gingerBill
2022-08-08 12:11:30 +01:00
parent 4912ecc3ea
commit 4aca9372a6
4 changed files with 50 additions and 75 deletions
+8 -5
View File
@@ -194,12 +194,15 @@ __slice_resize :: proc(array_: ^$T/[]$E, new_count: int, allocator: Allocator, l
new_size := new_count*size_of(T)
new_data, err := mem_resize(array.data, old_size, new_size, align_of(T), allocator, loc)
if new_data == nil || err != nil {
if err != nil {
return false
}
array.data = new_data
array.len = new_count
return true
if new_data != nil || elem_size == 0 {
array.data = raw_data(new_data)
array.len = new_count
return true
}
return false
}
__dynamic_map_reset_entries :: proc(using header: Map_Header, loc := #caller_location) {
@@ -207,7 +210,7 @@ __dynamic_map_reset_entries :: proc(using header: Map_Header, loc := #caller_loc
m.hashes[i] = -1
}
for i in 0 ..< m.entries.len {
for i in 0..<m.entries.len {
entry_header := __dynamic_map_get_entry(header, i)
entry_hash := __get_map_hash_from_entry(header, entry_header)
entry_header.next = -1