diff --git a/src/libcore/sys.rs b/src/libcore/sys.rs index 8eee6088630..cff945ad069 100644 --- a/src/libcore/sys.rs +++ b/src/libcore/sys.rs @@ -65,6 +65,7 @@ pure fn shape_le(x1: &T, x2: &T) -> bool { * Useful for calling certain function in the Rust runtime or otherwise * performing dark magick. */ +#[inline(always)] pure fn get_type_desc() -> *TypeDesc { unchecked { rusti::get_tydesc::() as *TypeDesc } } @@ -93,6 +94,7 @@ pure fn pref_align_of() -> uint { } /// Returns the refcount of a shared box (as just before calling this) +#[inline(always)] pure fn refcount(+t: @T) -> uint { unsafe { let ref_ptr: *uint = unsafe::reinterpret_cast(&t); diff --git a/src/libcore/unsafe.rs b/src/libcore/unsafe.rs index 8875fc1d0ea..2c7ebe642cb 100644 --- a/src/libcore/unsafe.rs +++ b/src/libcore/unsafe.rs @@ -51,6 +51,7 @@ unsafe fn bump_box_refcount(+t: @T) { forget(move t); } * * assert transmute("L") == ~[76u8, 0u8]; */ +#[inline(always)] unsafe fn transmute(-thing: L) -> G { debug!(">>> in transmute! <<<"); debug!("transmute 1: %?", &thing); @@ -61,26 +62,33 @@ unsafe fn transmute(-thing: L) -> G { } /// Coerce an immutable reference to be mutable. +#[inline(always)] unsafe fn transmute_mut(+ptr: &a/T) -> &a/mut T { transmute(move ptr) } /// Coerce a mutable reference to be immutable. +#[inline(always)] unsafe fn transmute_immut(+ptr: &a/mut T) -> &a/T { transmute(move ptr) } /// Coerce a borrowed pointer to have an arbitrary associated region. +#[inline(always)] unsafe fn transmute_region(+ptr: &a/T) -> &b/T { transmute(move ptr) } /// Coerce an immutable reference to be mutable. +#[inline(always)] unsafe fn transmute_mut_unsafe(+ptr: *const T) -> *mut T { transmute(ptr) } /// Coerce an immutable reference to be mutable. +#[inline(always)] unsafe fn transmute_immut_unsafe(+ptr: *const T) -> *T { transmute(ptr) } /// Coerce a borrowed mutable pointer to have an arbitrary associated region. +#[inline(always)] unsafe fn transmute_mut_region(+ptr: &a/mut T) -> &b/mut T { transmute(move ptr) } /// Transforms lifetime of the second pointer to match the first. +#[inline(always)] unsafe fn copy_lifetime(_ptr: &a/S, ptr: &T) -> &a/T { transmute_region(ptr) } diff --git a/src/libcore/util.rs b/src/libcore/util.rs index cc3d6dded6f..39589419beb 100644 --- a/src/libcore/util.rs +++ b/src/libcore/util.rs @@ -9,9 +9,11 @@ use cmp::Eq; */ /// The identity function. +#[inline(always)] pure fn id(+x: T) -> T { move x } /// Ignores a value. +#[inline(always)] pure fn ignore(+_x: T) { } /// Sets `*ptr` to `new_value`, invokes `op()`, and then restores the