aboutsummaryrefslogtreecommitdiff
path: root/base/runtime
diff options
context:
space:
mode:
authorTetralux <tetraluxonpc@gmail.com>2024-11-16 05:49:25 +0000
committerTetralux <tetraluxonpc@gmail.com>2024-11-16 06:13:12 +0000
commit2f85257bad7a4089ae20564f29e2bb629c03b656 (patch)
tree8e0007804bb763a2d58fb91cf358d8c0660a7529 /base/runtime
parent0781871efdcfeda13d3d8d51df62b5e578da774a (diff)
[runtime] `make(map[K]V)` should not allocate any capacity
`make(map[K]V)` was resolving to `make_map_cap()` which allocates initial capacity when it wasn't intended to. It now calls `make_map()` which doesn't allocate any capacity. Both `make(map[K]V)` and `make(map[K]V, allocator)` will NOT allocate initial capacity now.
Diffstat (limited to 'base/runtime')
-rw-r--r--base/runtime/core_builtin.odin4
1 files changed, 2 insertions, 2 deletions
diff --git a/base/runtime/core_builtin.odin b/base/runtime/core_builtin.odin
index 8b7a5004a..d28dadd02 100644
--- a/base/runtime/core_builtin.odin
+++ b/base/runtime/core_builtin.odin
@@ -388,7 +388,7 @@ _make_dynamic_array_len_cap :: proc(array: ^Raw_Dynamic_Array, size_of_elem, ali
//
// Note: Prefer using the procedure group `make`.
@(builtin, require_results)
-make_map :: proc($T: typeid/map[$K]$E, allocator := context.allocator) -> (m: T) {
+make_map :: proc($T: typeid/map[$K]$E, allocator := context.allocator, loc := #caller_location) -> (m: T) {
m.allocator = allocator
return m
}
@@ -399,7 +399,7 @@ make_map :: proc($T: typeid/map[$K]$E, allocator := context.allocator) -> (m: T)
//
// Note: Prefer using the procedure group `make`.
@(builtin, require_results)
-make_map_cap :: proc($T: typeid/map[$K]$E, #any_int capacity: int = 1<<MAP_MIN_LOG2_CAPACITY, allocator := context.allocator, loc := #caller_location) -> (m: T, err: Allocator_Error) #optional_allocator_error {
+make_map_cap :: proc($T: typeid/map[$K]$E, #any_int capacity: int, allocator := context.allocator, loc := #caller_location) -> (m: T, err: Allocator_Error) #optional_allocator_error {
make_map_expr_error_loc(loc, capacity)
context.allocator = allocator