Skip to content

Commit

Permalink
explain n >> 2
Browse files Browse the repository at this point in the history
  • Loading branch information
jonhoo committed Jan 25, 2020
1 parent a5e7cea commit 3b0c4ca
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const DEFAULT_CAPACITY: usize = 16;
/// The load factor for this table. Overrides of this value in
/// constructors affect only the initial table capacity. The
/// actual floating point value isn't normally used -- it is
/// simpler to use expressions such as `n - (n >>> 2)` for
/// simpler to use expressions such as `n - (n >> 2)` for
/// the associated resizing threshold.
const LOAD_FACTOR: f64 = 0.75;

Expand Down Expand Up @@ -318,6 +318,7 @@ where
let new_table = Owned::new(Table::new(n));
table = new_table.into_shared(guard);
self.table.store(table, Ordering::SeqCst);
// sc = ¾ n = n - n/4 = n - (n >> 2)
sc = n as isize - (n >> 2) as isize;
}
self.size_ctl.store(sc, Ordering::SeqCst);
Expand Down

0 comments on commit 3b0c4ca

Please sign in to comment.