Skip to content

Commit 4ce2ee1

Browse files
committed
Add a bunch of inline hints.
1 parent 3c14dae commit 4ce2ee1

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

src/libcore/sys.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ pure fn shape_le<T:Ord>(x1: &T, x2: &T) -> bool {
6565
* Useful for calling certain function in the Rust runtime or otherwise
6666
* performing dark magick.
6767
*/
68+
#[inline(always)]
6869
pure fn get_type_desc<T>() -> *TypeDesc {
6970
unchecked { rusti::get_tydesc::<T>() as *TypeDesc }
7071
}
@@ -93,6 +94,7 @@ pure fn pref_align_of<T>() -> uint {
9394
}
9495

9596
/// Returns the refcount of a shared box (as just before calling this)
97+
#[inline(always)]
9698
pure fn refcount<T>(+t: @T) -> uint {
9799
unsafe {
98100
let ref_ptr: *uint = unsafe::reinterpret_cast(&t);

src/libcore/unsafe.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ unsafe fn bump_box_refcount<T>(+t: @T) { forget(move t); }
5151
*
5252
* assert transmute("L") == ~[76u8, 0u8];
5353
*/
54+
#[inline(always)]
5455
unsafe fn transmute<L, G>(-thing: L) -> G {
5556
debug!(">>> in transmute! <<<");
5657
debug!("transmute 1: %?", &thing);
@@ -61,26 +62,33 @@ unsafe fn transmute<L, G>(-thing: L) -> G {
6162
}
6263

6364
/// Coerce an immutable reference to be mutable.
65+
#[inline(always)]
6466
unsafe fn transmute_mut<T>(+ptr: &a/T) -> &a/mut T { transmute(move ptr) }
6567

6668
/// Coerce a mutable reference to be immutable.
69+
#[inline(always)]
6770
unsafe fn transmute_immut<T>(+ptr: &a/mut T) -> &a/T { transmute(move ptr) }
6871

6972
/// Coerce a borrowed pointer to have an arbitrary associated region.
73+
#[inline(always)]
7074
unsafe fn transmute_region<T>(+ptr: &a/T) -> &b/T { transmute(move ptr) }
7175

7276
/// Coerce an immutable reference to be mutable.
77+
#[inline(always)]
7378
unsafe fn transmute_mut_unsafe<T>(+ptr: *const T) -> *mut T { transmute(ptr) }
7479

7580
/// Coerce an immutable reference to be mutable.
81+
#[inline(always)]
7682
unsafe fn transmute_immut_unsafe<T>(+ptr: *const T) -> *T { transmute(ptr) }
7783

7884
/// Coerce a borrowed mutable pointer to have an arbitrary associated region.
85+
#[inline(always)]
7986
unsafe fn transmute_mut_region<T>(+ptr: &a/mut T) -> &b/mut T {
8087
transmute(move ptr)
8188
}
8289

8390
/// Transforms lifetime of the second pointer to match the first.
91+
#[inline(always)]
8492
unsafe fn copy_lifetime<S,T>(_ptr: &a/S, ptr: &T) -> &a/T {
8593
transmute_region(ptr)
8694
}

src/libcore/util.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@ use cmp::Eq;
99
*/
1010

1111
/// The identity function.
12+
#[inline(always)]
1213
pure fn id<T>(+x: T) -> T { move x }
1314

1415
/// Ignores a value.
16+
#[inline(always)]
1517
pure fn ignore<T>(+_x: T) { }
1618

1719
/// Sets `*ptr` to `new_value`, invokes `op()`, and then restores the

0 commit comments

Comments
 (0)