mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-06 05:44:20 +00:00
std.ArrayHashMap: base linear_scan_max on cache line size
This commit is contained in:
parent
58f928814d
commit
53216d2f22
1 changed files with 7 additions and 4 deletions
|
|
@ -605,7 +605,10 @@ pub fn ArrayHashMapUnmanaged(
|
|||
|
||||
const Self = @This();
|
||||
|
||||
const linear_scan_max = 8;
|
||||
const linear_scan_max = @as(comptime_int, @max(1, @as(comptime_int, @min(
|
||||
std.atomic.cache_line / @as(comptime_int, @max(1, @sizeOf(Hash))),
|
||||
std.atomic.cache_line / @as(comptime_int, @max(1, @sizeOf(K))),
|
||||
))));
|
||||
|
||||
const RemovalType = enum {
|
||||
swap,
|
||||
|
|
@ -2393,7 +2396,7 @@ test "shrink" {
|
|||
defer map.deinit();
|
||||
|
||||
// This test is more interesting if we insert enough entries to allocate the index header.
|
||||
const num_entries = 20;
|
||||
const num_entries = 200;
|
||||
var i: i32 = 0;
|
||||
while (i < num_entries) : (i += 1)
|
||||
try testing.expect((try map.fetchPut(i, i * 10)) == null);
|
||||
|
|
@ -2404,7 +2407,7 @@ test "shrink" {
|
|||
// Test `shrinkRetainingCapacity`.
|
||||
map.shrinkRetainingCapacity(17);
|
||||
try testing.expect(map.count() == 17);
|
||||
try testing.expect(map.capacity() == 20);
|
||||
try testing.expect(map.capacity() >= num_entries);
|
||||
i = 0;
|
||||
while (i < num_entries) : (i += 1) {
|
||||
const gop = try map.getOrPut(i);
|
||||
|
|
@ -2453,7 +2456,7 @@ test "reIndex" {
|
|||
defer map.deinit();
|
||||
|
||||
// Populate via the API.
|
||||
const num_indexed_entries = 20;
|
||||
const num_indexed_entries = 200;
|
||||
var i: i32 = 0;
|
||||
while (i < num_indexed_entries) : (i += 1)
|
||||
try testing.expect((try map.fetchPut(i, i * 10)) == null);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue