| ... | @@ -605,7 +605,10 @@ pub fn ArrayHashMapUnmanaged( | ... | @@ -605,7 +605,10 @@ pub fn ArrayHashMapUnmanaged( |
| 605 | | 605 | |
| 606 | const Self = @This(); | 606 | const Self = @This(); |
| 607 | | 607 | |
| 608 | const linear_scan_max = 8; | 608 | const linear_scan_max = @as(comptime_int, @max(1, @as(comptime_int, @min( |
| | 609 | std.atomic.cache_line / @as(comptime_int, @max(1, @sizeOf(Hash))), |
| | 610 | std.atomic.cache_line / @as(comptime_int, @max(1, @sizeOf(K))), |
| | 611 | )))); |
| 609 | | 612 | |
| 610 | const RemovalType = enum { | 613 | const RemovalType = enum { |
| 611 | swap, | 614 | swap, |
| ... | @@ -2393,7 +2396,7 @@ test "shrink" { | ... | @@ -2393,7 +2396,7 @@ test "shrink" { |
| 2393 | defer map.deinit(); | 2396 | defer map.deinit(); |
| 2394 | | 2397 | |
| 2395 | // This test is more interesting if we insert enough entries to allocate the index header. | 2398 | // This test is more interesting if we insert enough entries to allocate the index header. |
| 2396 | const num_entries = 20; | 2399 | const num_entries = 200; |
| 2397 | var i: i32 = 0; | 2400 | var i: i32 = 0; |
| 2398 | while (i < num_entries) : (i += 1) | 2401 | while (i < num_entries) : (i += 1) |
| 2399 | try testing.expect((try map.fetchPut(i, i * 10)) == null); | 2402 | try testing.expect((try map.fetchPut(i, i * 10)) == null); |
| ... | @@ -2404,7 +2407,7 @@ test "shrink" { | ... | @@ -2404,7 +2407,7 @@ test "shrink" { |
| 2404 | // Test `shrinkRetainingCapacity`. | 2407 | // Test `shrinkRetainingCapacity`. |
| 2405 | map.shrinkRetainingCapacity(17); | 2408 | map.shrinkRetainingCapacity(17); |
| 2406 | try testing.expect(map.count() == 17); | 2409 | try testing.expect(map.count() == 17); |
| 2407 | try testing.expect(map.capacity() == 20); | 2410 | try testing.expect(map.capacity() >= num_entries); |
| 2408 | i = 0; | 2411 | i = 0; |
| 2409 | while (i < num_entries) : (i += 1) { | 2412 | while (i < num_entries) : (i += 1) { |
| 2410 | const gop = try map.getOrPut(i); | 2413 | const gop = try map.getOrPut(i); |
| ... | @@ -2453,7 +2456,7 @@ test "reIndex" { | ... | @@ -2453,7 +2456,7 @@ test "reIndex" { |
| 2453 | defer map.deinit(); | 2456 | defer map.deinit(); |
| 2454 | | 2457 | |
| 2455 | // Populate via the API. | 2458 | // Populate via the API. |
| 2456 | const num_indexed_entries = 20; | 2459 | const num_indexed_entries = 200; |
| 2457 | var i: i32 = 0; | 2460 | var i: i32 = 0; |
| 2458 | while (i < num_indexed_entries) : (i += 1) | 2461 | while (i < num_indexed_entries) : (i += 1) |
| 2459 | try testing.expect((try map.fetchPut(i, i * 10)) == null); | 2462 | try testing.expect((try map.fetchPut(i, i * 10)) == null); |