Skip to content

Commit

Permalink
Cargo fmt fix
Browse files Browse the repository at this point in the history
  • Loading branch information
MicroProofs committed Dec 7, 2024
1 parent 4d7a242 commit ddc58b9
Showing 1 changed file with 29 additions and 30 deletions.
59 changes: 29 additions & 30 deletions crates/uplc/src/machine/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1709,36 +1709,35 @@ impl DefaultFunction {
DefaultFunction::FindFirstSetBit => {
let bytes = args[0].unwrap_byte_string()?;

let first_bit =
bytes
.iter()
.rev()
.enumerate()
.find_map(|(byte_index, value)| {
let value = value.reverse_bits();

let first_bit: Option<usize> = if value >= 128 {
Some(0)
} else if value >= 64 {
Some(1)
} else if value >= 32 {
Some(2)
} else if value >= 16 {
Some(3)
} else if value >= 8 {
Some(4)
} else if value >= 4 {
Some(5)
} else if value >= 2 {
Some(6)
} else if value >= 1 {
Some(7)
} else {
None
};

first_bit.map(|bit| isize::try_from(bit + byte_index * 8).unwrap())
});
let first_bit = bytes
.iter()
.rev()
.enumerate()
.find_map(|(byte_index, value)| {
let value = value.reverse_bits();

let first_bit: Option<usize> = if value >= 128 {
Some(0)
} else if value >= 64 {
Some(1)
} else if value >= 32 {
Some(2)
} else if value >= 16 {
Some(3)
} else if value >= 8 {
Some(4)
} else if value >= 4 {
Some(5)
} else if value >= 2 {
Some(6)
} else if value >= 1 {
Some(7)
} else {
None
};

first_bit.map(|bit| isize::try_from(bit + byte_index * 8).unwrap())
});

Ok(Value::integer(first_bit.unwrap_or(-1).into()))
}
Expand Down

0 comments on commit ddc58b9

Please sign in to comment.