Skip to content

Commit

Permalink
fix comments
Browse files Browse the repository at this point in the history
  • Loading branch information
mcroomp committed Apr 12, 2024
1 parent 5a3e6f7 commit 0d7cecf
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/structs/branch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ impl Branch {

#[inline(always)]
pub fn record_and_update_bit(&mut self, bit: bool) {
// rotation is use to update either the true or false counter
// rotation is used to update either the true or false counter
// this allows the same code to be used without branching,
// which makes the CPU about 20% happier
let orig = self.counts.rotate_left(bit as u32 * 8);
Expand All @@ -84,7 +84,7 @@ impl Branch {
// normalize, except in special case where we have 0xff or more same bits in a row
// in which case we want to bias the probability to get better compression
//
// Branch prediction realizes that this section is not often executed
// CPU branch prediction soon realizes that this section is not often executed
// and will optimize for the common case where the counts are not 0xff.
let mask = if orig == 0xff01 { 0xff00 } else { 0x8100 };
sum = ((1 + (sum & 0xff)) >> 1) | mask;
Expand Down

0 comments on commit 0d7cecf

Please sign in to comment.