From f986747a8efcb86c16452a4c6b9bf4b4852eef6d Mon Sep 17 00:00:00 2001 From: Brendan Hansen Date: Tue, 12 Sep 2023 15:18:14 -0500 Subject: [PATCH] added: ability to set allocator for maps --- core/container/map.onyx | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/core/container/map.onyx b/core/container/map.onyx index 4d7e654d..7aff718c 100644 --- a/core/container/map.onyx +++ b/core/container/map.onyx @@ -67,27 +67,27 @@ Map :: struct (Key_Type: type_expr, Value_Type: type_expr) where ValidKey(Key_Ty """ #overload __make_overload :: macro (x: &Map($K, $V), allocator := context.allocator) => - #this_package.make(K, V); + #this_package.make(K, V, allocator); #doc """ Creates and initializes a new map using the types provided. """ -make :: macro ($Key: type_expr, $Value: type_expr) -> Map(Key, Value) { +make :: macro ($Key: type_expr, $Value: type_expr, allocator := context.allocator) -> Map(Key, Value) { map : Map(Key, Value); - #this_package.init(&map); + #this_package.init(&map, allocator); return map; } #doc "Initializes a map." -init :: (use map: &Map($K, $V)) { +init :: (map: &Map($K, $V), allocator := context.allocator) { __initialize(map); - allocator = context.allocator; + map.allocator = allocator; - hashes = builtin.make([] u32, 8, allocator=allocator); - array.fill(hashes, -1); + map.hashes = builtin.make([] u32, 8, allocator=allocator); + array.fill(map.hashes, -1); - array.init(&entries, allocator=allocator); + array.init(&map.entries, allocator=allocator); } #doc "Allows for deletion of a Map using `delete(&map)`." -- 2.25.1