arena,std,serialize: remove some unnecessary transmutes.
`as`-able transmutes, duplication and manual slice decomposition are silly.
This commit is contained in:
parent
4cc723dc22
commit
9e8d5aa29e
@ -167,13 +167,12 @@ unsafe fn destroy_chunk(chunk: &Chunk) {
|
||||
// is necessary in order to properly do cleanup if a failure occurs
|
||||
// during an initializer.
|
||||
#[inline]
|
||||
unsafe fn bitpack_tydesc_ptr(p: *TyDesc, is_done: bool) -> uint {
|
||||
let p_bits: uint = transmute(p);
|
||||
p_bits | (is_done as uint)
|
||||
fn bitpack_tydesc_ptr(p: *TyDesc, is_done: bool) -> uint {
|
||||
p as uint | (is_done as uint)
|
||||
}
|
||||
#[inline]
|
||||
unsafe fn un_bitpack_tydesc_ptr(p: uint) -> (*TyDesc, bool) {
|
||||
(transmute(p & !1), p & 1 == 1)
|
||||
fn un_bitpack_tydesc_ptr(p: uint) -> (*TyDesc, bool) {
|
||||
((p & !1) as *TyDesc, p & 1 == 1)
|
||||
}
|
||||
|
||||
impl Arena {
|
||||
|
@ -161,9 +161,7 @@ pub mod reader {
|
||||
];
|
||||
|
||||
unsafe {
|
||||
let (ptr, _): (*u8, uint) = transmute(data);
|
||||
let ptr = ptr.offset(start as int);
|
||||
let ptr: *i32 = transmute(ptr);
|
||||
let ptr = data.as_ptr().offset(start as int) as *i32;
|
||||
let val = from_be32(*ptr) as u32;
|
||||
|
||||
let i = (val >> 28u) as uint;
|
||||
|
@ -351,10 +351,8 @@ impl Float for f32 {
|
||||
static EXP_MASK: u32 = 0x7f800000;
|
||||
static MAN_MASK: u32 = 0x007fffff;
|
||||
|
||||
match (
|
||||
unsafe { ::cast::transmute::<f32,u32>(*self) } & MAN_MASK,
|
||||
unsafe { ::cast::transmute::<f32,u32>(*self) } & EXP_MASK,
|
||||
) {
|
||||
let bits: u32 = unsafe {::cast::transmute(*self)};
|
||||
match (bits & MAN_MASK, bits & EXP_MASK) {
|
||||
(0, 0) => FPZero,
|
||||
(_, 0) => FPSubnormal,
|
||||
(0, EXP_MASK) => FPInfinite,
|
||||
|
@ -353,10 +353,8 @@ impl Float for f64 {
|
||||
static EXP_MASK: u64 = 0x7ff0000000000000;
|
||||
static MAN_MASK: u64 = 0x000fffffffffffff;
|
||||
|
||||
match (
|
||||
unsafe { ::cast::transmute::<f64,u64>(*self) } & MAN_MASK,
|
||||
unsafe { ::cast::transmute::<f64,u64>(*self) } & EXP_MASK,
|
||||
) {
|
||||
let bits: u64 = unsafe {::cast::transmute(*self)};
|
||||
match (bits & MAN_MASK, bits & EXP_MASK) {
|
||||
(0, 0) => FPZero,
|
||||
(_, 0) => FPSubnormal,
|
||||
(0, EXP_MASK) => FPInfinite,
|
||||
|
Loading…
Reference in New Issue
Block a user