aboutsummaryrefslogtreecommitdiff
path: root/lib/std
diff options
context:
space:
mode:
authormarko <marko03kostic@protonmail.com>2025-09-11 00:14:01 +0200
committerAndrew Kelley <andrew@ziglang.org>2025-09-11 00:18:37 -0700
commitfb3afc8d3da547c1b73c9cf18cd1a394b0ebefbc (patch)
treea2cbdbab26ea7af03443bc58839a53e5759b52c2 /lib/std
parentbfda12efcf2f6b4bc6803f520108b7ce05636965 (diff)
downloadzig-fb3afc8d3da547c1b73c9cf18cd1a394b0ebefbc.tar.gz
zig-fb3afc8d3da547c1b73c9cf18cd1a394b0ebefbc.zip
use pointer subtraction
Diffstat (limited to 'lib/std')
-rw-r--r--lib/std/hash_map.zig3
1 files changed, 1 insertions, 2 deletions
diff --git a/lib/std/hash_map.zig b/lib/std/hash_map.zig
index eb40724f20..85424fe45e 100644
--- a/lib/std/hash_map.zig
+++ b/lib/std/hash_map.zig
@@ -1267,12 +1267,11 @@ pub fn HashMapUnmanaged(
/// TODO: answer the question in these doc comments, does this
/// increase the unused capacity by one?
pub fn removeByPtr(self: *Self, key_ptr: *K) void {
- // TODO: replace with pointer subtraction once supported by zig
// if @sizeOf(K) == 0 then there is at most one item in the hash
// map, which is assumed to exist as key_ptr must be valid. This
// item must be at index 0.
const idx = if (@sizeOf(K) > 0)
- (@intFromPtr(key_ptr) - @intFromPtr(self.keys())) / @sizeOf(K)
+ (key_ptr - self.keys())
else
0;