about summary refs log tree commit diff
diff options
context:
space:
mode:
authorGraydon Hoare <graydon@mozilla.com>2012-09-11 15:57:32 -0700
committerGraydon Hoare <graydon@mozilla.com>2012-09-12 14:48:18 -0700
commit4ce2ee12beea76727fe2ced87748c31725ce4e98 (patch)
treea837e441e337093f546d659507f8252f44cb7be6
parent3c14dae4a64b791eec86a11f04fcbeab5df23911 (diff)
downloadrust-4ce2ee12beea76727fe2ced87748c31725ce4e98.tar.gz
rust-4ce2ee12beea76727fe2ced87748c31725ce4e98.zip
Add a bunch of inline hints.
-rw-r--r--src/libcore/sys.rs2
-rw-r--r--src/libcore/unsafe.rs8
-rw-r--r--src/libcore/util.rs2
3 files changed, 12 insertions, 0 deletions
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<T:Ord>(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<T>() -> *TypeDesc {
     unchecked { rusti::get_tydesc::<T>() as *TypeDesc }
 }
@@ -93,6 +94,7 @@ pure fn pref_align_of<T>() -> uint {
 }
 
 /// Returns the refcount of a shared box (as just before calling this)
+#[inline(always)]
 pure fn refcount<T>(+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: @T) { forget(move t); }
  *
  *     assert transmute("L") == ~[76u8, 0u8];
  */
+#[inline(always)]
 unsafe fn transmute<L, G>(-thing: L) -> G {
     debug!(">>> in transmute! <<<");
     debug!("transmute 1: %?", &thing);
@@ -61,26 +62,33 @@ unsafe fn transmute<L, G>(-thing: L) -> G {
 }
 
 /// Coerce an immutable reference to be mutable.
+#[inline(always)]
 unsafe fn transmute_mut<T>(+ptr: &a/T) -> &a/mut T { transmute(move ptr) }
 
 /// Coerce a mutable reference to be immutable.
+#[inline(always)]
 unsafe fn transmute_immut<T>(+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<T>(+ptr: &a/T) -> &b/T { transmute(move ptr) }
 
 /// Coerce an immutable reference to be mutable.
+#[inline(always)]
 unsafe fn transmute_mut_unsafe<T>(+ptr: *const T) -> *mut T { transmute(ptr) }
 
 /// Coerce an immutable reference to be mutable.
+#[inline(always)]
 unsafe fn transmute_immut_unsafe<T>(+ptr: *const T) -> *T { transmute(ptr) }
 
 /// Coerce a borrowed mutable pointer to have an arbitrary associated region.
+#[inline(always)]
 unsafe fn transmute_mut_region<T>(+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<S,T>(_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<T>(+x: T) -> T { move x }
 
 /// Ignores a value.
+#[inline(always)]
 pure fn ignore<T>(+_x: T) { }
 
 /// Sets `*ptr` to `new_value`, invokes `op()`, and then restores the