mirror of
https://github.com/swc-project/swc.git
synced 2024-12-25 14:43:33 +03:00
refactor(es/ast): Avoid transmute
in impl of Hash
for Number
(#7771)
**Description:** [`f64::to_bits()`](https://doc.rust-lang.org/stable/std/primitive.f64.html#method.to_bits) does the same thing.
This commit is contained in:
parent
76c78f8794
commit
2258274233
@ -2,7 +2,6 @@ use std::{
|
||||
borrow::Cow,
|
||||
fmt::{self, Display, Formatter},
|
||||
hash::{Hash, Hasher},
|
||||
mem,
|
||||
};
|
||||
|
||||
use num_bigint::BigInt as BigIntValue;
|
||||
@ -353,7 +352,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 {
|
||||
|
Loading…
Reference in New Issue
Block a user