Skip to content

Commit

Permalink
Use f64::to_bits() instead of transmute in hash impl
Browse files Browse the repository at this point in the history
  • Loading branch information
Manishearth committed Aug 7, 2023
1 parent 223643f commit 59d2687
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion crates/swc_ecma_ast/src/lit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ impl EqIgnoreSpan for Number {
impl Hash for Number {
fn hash<H: Hasher>(&self, state: &mut H) {
fn integer_decode(val: f64) -> (u64, i16, i8) {
let bits: u64 = unsafe { mem::transmute(val) };
let bits: u64 = val.to_bits();
let sign: i8 = if bits >> 63 == 0 { 1 } else { -1 };
let mut exponent: i16 = ((bits >> 52) & 0x7ff) as i16;
let mantissa = if exponent == 0 {
Expand Down

0 comments on commit 59d2687

Please sign in to comment.