From f98cffc615bb7ea73eee3bd24ae8a957fe8ebb82 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Sat, 8 Aug 2020 15:59:03 -0700 Subject: [PATCH] std: general purpose allocator: use AutoHashMap As pointed out by Sahnvour, AutoHashMap is both more convenient and will have better performance in this case. --- lib/std/heap/general_purpose_allocator.zig | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/lib/std/heap/general_purpose_allocator.zig b/lib/std/heap/general_purpose_allocator.zig index dbab929c5c..cb7f36fcc3 100644 --- a/lib/std/heap/general_purpose_allocator.zig +++ b/lib/std/heap/general_purpose_allocator.zig @@ -189,7 +189,7 @@ pub fn GeneralPurposeAllocator(comptime config: Config) type { std.debug.dumpStackTrace(stack_trace); } }; - const LargeAllocTable = std.HashMapUnmanaged(usize, LargeAlloc, hash_addr, eql_addr, false); + const LargeAllocTable = std.AutoHashMapUnmanaged(usize, LargeAlloc); // Bucket: In memory, in order: // * BucketHeader @@ -609,17 +609,6 @@ const TraceKind = enum { free, }; -fn hash_addr(addr: usize) u32 { - if (@sizeOf(usize) == @sizeOf(u32)) - return addr; - comptime assert(@sizeOf(usize) == 8); - return @intCast(u32, addr >> 32) ^ @truncate(u32, addr); -} - -fn eql_addr(a: usize, b: usize) bool { - return a == b; -} - const test_config = Config{}; test "small allocations - free in same order" {