authorgravatar for mail@linusgroh.deLinus Groh <mail@linusgroh.de> 2023-07-19 18:17:03+01:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-07-20 12:52:05-07:00
log3bada8e3ce9ba72f57c6fbed100c76fd40ba0d15
tree4c1ded13288e198e10c2f53389e1194661e352c7
parent772debb03a3f15cfba5d100925260d86c1fcc9dc

std.hash_map: Fix casing of keyPtr variables

The only case where those should be written in camelCase is if they were function pointers, which they aren't.

1 files changed, 15 insertions(+), 15 deletions(-)

lib/std/hash_map.zig+15-15
...@@ -639,11 +639,11 @@ pub fn HashMap(...@@ -639,11 +639,11 @@ pub fn HashMap(
639 return self.unmanaged.removeAdapted(key, ctx);639 return self.unmanaged.removeAdapted(key, ctx);
640 }640 }
641641
642 /// Delete the entry with key pointed to by keyPtr from the hash map.642 /// Delete the entry with key pointed to by key_ptr from the hash map.
643 /// keyPtr is assumed to be a valid pointer to a key that is present643 /// key_ptr is assumed to be a valid pointer to a key that is present
644 /// in the hash map.644 /// in the hash map.
645 pub fn removeByPtr(self: *Self, keyPtr: *K) void {645 pub fn removeByPtr(self: *Self, key_ptr: *K) void {
646 self.unmanaged.removeByPtr(keyPtr);646 self.unmanaged.removeByPtr(key_ptr);
647 }647 }
648648
649 /// Creates a copy of this map, using the same allocator649 /// Creates a copy of this map, using the same allocator
...@@ -1433,16 +1433,16 @@ pub fn HashMapUnmanaged(...@@ -1433,16 +1433,16 @@ pub fn HashMapUnmanaged(
1433 return false;1433 return false;
1434 }1434 }
14351435
1436 /// Delete the entry with key pointed to by keyPtr from the hash map.1436 /// Delete the entry with key pointed to by key_ptr from the hash map.
1437 /// keyPtr is assumed to be a valid pointer to a key that is present1437 /// key_ptr is assumed to be a valid pointer to a key that is present
1438 /// in the hash map.1438 /// in the hash map.
1439 pub fn removeByPtr(self: *Self, keyPtr: *K) void {1439 pub fn removeByPtr(self: *Self, key_ptr: *K) void {
1440 // TODO: replace with pointer subtraction once supported by zig1440 // TODO: replace with pointer subtraction once supported by zig
1441 // if @sizeOf(K) == 0 then there is at most one item in the hash1441 // if @sizeOf(K) == 0 then there is at most one item in the hash
1442 // map, which is assumed to exist as keyPtr must be valid. This1442 // map, which is assumed to exist as key_ptr must be valid. This
1443 // item must be at index 0.1443 // item must be at index 0.
1444 const idx = if (@sizeOf(K) > 0)1444 const idx = if (@sizeOf(K) > 0)
1445 (@intFromPtr(keyPtr) - @intFromPtr(self.keys())) / @sizeOf(K)1445 (@intFromPtr(key_ptr) - @intFromPtr(self.keys())) / @sizeOf(K)
1446 else1446 else
1447 0;1447 0;
14481448
...@@ -2166,10 +2166,10 @@ test "std.hash_map removeByPtr" {...@@ -2166,10 +2166,10 @@ test "std.hash_map removeByPtr" {
21662166
2167 i = 0;2167 i = 0;
2168 while (i < 10) : (i += 1) {2168 while (i < 10) : (i += 1) {
2169 const keyPtr = map.getKeyPtr(i);2169 const key_ptr = map.getKeyPtr(i);
2170 try testing.expect(keyPtr != null);2170 try testing.expect(key_ptr != null);
21712171
2172 if (keyPtr) |ptr| {2172 if (key_ptr) |ptr| {
2173 map.removeByPtr(ptr);2173 map.removeByPtr(ptr);
2174 }2174 }
2175 }2175 }
...@@ -2185,10 +2185,10 @@ test "std.hash_map removeByPtr 0 sized key" {...@@ -2185,10 +2185,10 @@ test "std.hash_map removeByPtr 0 sized key" {
21852185
2186 try testing.expect(map.count() == 1);2186 try testing.expect(map.count() == 1);
21872187
2188 const keyPtr = map.getKeyPtr(0);2188 const key_ptr = map.getKeyPtr(0);
2189 try testing.expect(keyPtr != null);2189 try testing.expect(key_ptr != null);
21902190
2191 if (keyPtr) |ptr| {2191 if (key_ptr) |ptr| {
2192 map.removeByPtr(ptr);2192 map.removeByPtr(ptr);
2193 }2193 }
21942194