From 690077c52120baa2ac33278a5b02345b20721096 Mon Sep 17 00:00:00 2001 From: David Rubin Date: Sun, 15 Dec 2024 03:41:56 -0800 Subject: [PATCH] hashmap: remove `inline` from `getIndex` now that we have `@branchHint` --- lib/std/hash_map.zig | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/lib/std/hash_map.zig b/lib/std/hash_map.zig index e6f51dc6481d..2441b8714277 100644 --- a/lib/std/hash_map.zig +++ b/lib/std/hash_map.zig @@ -1187,17 +1187,13 @@ pub fn HashMapUnmanaged( } /// Find the index containing the data for the given key. - /// Whether this function returns null is almost always - /// branched on after this function returns, and this function - /// returns null/not null from separate code paths. We - /// want the optimizer to remove that branch and instead directly - /// fuse the basic blocks after the branch to the basic blocks - /// from this function. To encourage that, this function is - /// marked as inline. - inline fn getIndex(self: Self, key: anytype, ctx: anytype) ?usize { + fn getIndex(self: Self, key: anytype, ctx: anytype) ?usize { comptime verifyContext(@TypeOf(ctx), @TypeOf(key), K, Hash, false); if (self.size == 0) { + // We use cold instead of unlikely because even with unlikely, + // LLVM will want to fallthrough to this case. + @branchHint(.cold); return null; }