diff options
| author | fleandro <3987005+flga@users.noreply.github.com> | 2025-01-03 15:33:34 +0000 |
|---|---|---|
| committer | fleandro <3987005+flga@users.noreply.github.com> | 2025-01-03 15:33:34 +0000 |
| commit | e3de02eaa8b69ae615c3df1177f44f326ca5ac44 (patch) | |
| tree | e8c5e9291f83584833c556f8b5b4f76dc45c00e6 /base/runtime | |
| parent | fdd3b46c10dae9adbc1484a795ed119fbf4a0baa (diff) | |
runtime: map_cell_index_static produced wrong results when the number of elements per cell was a power of 2
Diffstat (limited to 'base/runtime')
| -rw-r--r-- | base/runtime/dynamic_map_internal.odin | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/base/runtime/dynamic_map_internal.odin b/base/runtime/dynamic_map_internal.odin index 3dded7716..281d4b88e 100644 --- a/base/runtime/dynamic_map_internal.odin +++ b/base/runtime/dynamic_map_internal.odin @@ -161,11 +161,11 @@ map_cell_index_static :: #force_inline proc "contextless" (cells: [^]Map_Cell($T // Compute the integer log 2 of N, this is the shift amount to index the // correct cell. Odin's intrinsics.count_leading_zeros does not produce a // constant, hence this approach. We only need to check up to N = 64. - SHIFT :: 1 when N < 2 else - 2 when N < 4 else - 3 when N < 8 else - 4 when N < 16 else - 5 when N < 32 else 6 + SHIFT :: 1 when N == 2 else + 2 when N == 4 else + 3 when N == 8 else + 4 when N == 16 else + 5 when N == 32 else 6 #assert(SHIFT <= MAP_CACHE_LINE_LOG2) // Unique case, no need to index data here since only one element. when N == 1 { |