Skip to content

Commit d54db4f

Browse files
committed
refactor: Remove usage of float instruction
1 parent ed680c4 commit d54db4f

1 file changed

Lines changed: 2 additions & 4 deletions

File tree

src/header/map.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ const FORWARD_SHIFT_THRESHOLD: usize = 512;
371371
// If growing the hash map would cause the load factor to drop bellow this
372372
// threshold, then instead of growing, the headermap is switched to the red
373373
// danger state and safe hashing is used instead.
374-
const LOAD_FACTOR_THRESHOLD: f32 = 0.2;
374+
const LOAD_FACTOR_THRESHOLD: usize = 5;
375375

376376
// Macro used to iterate the hash table starting at a given point, looping when
377377
// the end is hit.
@@ -1739,9 +1739,7 @@ impl<T> HeaderMap<T> {
17391739
let len = self.entries.len();
17401740

17411741
if self.danger.is_yellow() {
1742-
let load_factor = self.entries.len() as f32 / self.indices.len() as f32;
1743-
1744-
if load_factor >= LOAD_FACTOR_THRESHOLD {
1742+
if self.entries.len() * LOAD_FACTOR_THRESHOLD >= self.indices.len() {
17451743
// Transition back to green danger level
17461744
self.danger.set_green();
17471745

0 commit comments

Comments
 (0)