diff --git a/src/libextra/arc.rs b/src/libextra/arc.rs index 0618e7aaf65c9..2606a5c715ef4 100644 --- a/src/libextra/arc.rs +++ b/src/libextra/arc.rs @@ -59,7 +59,7 @@ pub struct Condvar<'self> { impl<'self> Condvar<'self> { /// Atomically exit the associated ARC and block until a signal is sent. - #[inline(always)] + #[inline(force)] pub fn wait(&self) { self.wait_on(0) } /** @@ -68,7 +68,7 @@ impl<'self> Condvar<'self> { * * wait() is equivalent to wait_on(0). */ - #[inline(always)] + #[inline(force)] pub fn wait_on(&self, condvar_id: uint) { assert!(!*self.failed); self.cond.wait_on(condvar_id); @@ -77,28 +77,28 @@ impl<'self> Condvar<'self> { } /// Wake up a blocked task. Returns false if there was no blocked task. - #[inline(always)] + #[inline(force)] pub fn signal(&self) -> bool { self.signal_on(0) } /** * Wake up a blocked task on a specified condvar (as * sync::cond.signal_on). Returns false if there was no blocked task. */ - #[inline(always)] + #[inline(force)] pub fn signal_on(&self, condvar_id: uint) -> bool { assert!(!*self.failed); self.cond.signal_on(condvar_id) } /// Wake up all blocked tasks. Returns the number of tasks woken. - #[inline(always)] + #[inline(force)] pub fn broadcast(&self) -> uint { self.broadcast_on(0) } /** * Wake up all blocked tasks on a specified condvar (as * sync::cond.broadcast_on). Returns the number of tasks woken. */ - #[inline(always)] + #[inline(force)] pub fn broadcast_on(&self, condvar_id: uint) -> uint { assert!(!*self.failed); self.cond.broadcast_on(condvar_id) @@ -199,7 +199,7 @@ impl MutexARC { * any tasks that subsequently try to access it (including those already * blocked on the mutex) will also fail immediately. */ - #[inline(always)] + #[inline] pub unsafe fn access(&self, blk: &fn(x: &mut T) -> U) -> U { unsafe { let state = self.x.get(); @@ -214,7 +214,7 @@ impl MutexARC { } /// As access(), but with a condvar, as sync::mutex.lock_cond(). - #[inline(always)] + #[inline] pub unsafe fn access_cond<'x, 'c, U>(&self, blk: &fn(x: &'x mut T, c: &'c Condvar) -> U) @@ -232,7 +232,7 @@ impl MutexARC { } // Common code for {mutex.access,rwlock.write}{,_cond}. -#[inline(always)] +#[inline(force)] #[doc(hidden)] fn check_poison(is_mutex: bool, failed: bool) { if failed { @@ -325,7 +325,7 @@ impl RWARC { * that other tasks won't block forever. As MutexARC.access, it will also * poison the ARC, so subsequent readers and writers will both also fail. */ - #[inline(always)] + #[inline] pub fn write(&self, blk: &fn(x: &mut T) -> U) -> U { unsafe { let state = self.x.get(); @@ -338,7 +338,7 @@ impl RWARC { } /// As write(), but with a condvar, as sync::rwlock.write_cond(). - #[inline(always)] + #[inline] pub fn write_cond<'x, 'c, U>(&self, blk: &fn(x: &'x mut T, c: &'c Condvar) -> U) -> U { diff --git a/src/libextra/arena.rs b/src/libextra/arena.rs index 2926d5958f16c..db4cf564babc5 100644 --- a/src/libextra/arena.rs +++ b/src/libextra/arena.rs @@ -119,7 +119,7 @@ pub fn Arena() -> Arena { arena_with_size(32u) } -#[inline(always)] +#[inline] fn round_up_to(base: uint, align: uint) -> uint { (base + (align - 1)) & !(align - 1) } @@ -156,12 +156,12 @@ unsafe fn destroy_chunk(chunk: &Chunk) { // initialized in the arena in the low bit of the tydesc pointer. This // is necessary in order to properly do cleanup if a failure occurs // during an initializer. -#[inline(always)] +#[inline] unsafe fn bitpack_tydesc_ptr(p: *TypeDesc, is_done: bool) -> uint { let p_bits: uint = transmute(p); p_bits | (is_done as uint) } -#[inline(always)] +#[inline] unsafe fn un_bitpack_tydesc_ptr(p: uint) -> (*TypeDesc, bool) { (transmute(p & !1), p & 1 == 1) } @@ -179,7 +179,7 @@ impl Arena { return self.alloc_pod_inner(n_bytes, align); } - #[inline(always)] + #[inline] fn alloc_pod_inner(&mut self, n_bytes: uint, align: uint) -> *u8 { unsafe { // XXX: Borrow check @@ -199,7 +199,7 @@ impl Arena { } } - #[inline(always)] + #[inline] fn alloc_pod<'a, T>(&'a mut self, op: &fn() -> T) -> &'a T { unsafe { let tydesc = sys::get_type_desc::(); @@ -223,7 +223,7 @@ impl Arena { return self.alloc_nonpod_inner(n_bytes, align); } - #[inline(always)] + #[inline] fn alloc_nonpod_inner(&mut self, n_bytes: uint, align: uint) -> (*u8, *u8) { unsafe { @@ -246,7 +246,7 @@ impl Arena { } } - #[inline(always)] + #[inline] fn alloc_nonpod<'a, T>(&'a mut self, op: &fn() -> T) -> &'a T { unsafe { let tydesc = sys::get_type_desc::(); @@ -268,7 +268,7 @@ impl Arena { } // The external interface - #[inline(always)] + #[inline] pub fn alloc<'a, T>(&'a mut self, op: &fn() -> T) -> &'a T { unsafe { // XXX: Borrow check diff --git a/src/libextra/bitv.rs b/src/libextra/bitv.rs index e3a15f76c786b..3c0d300dc211e 100644 --- a/src/libextra/bitv.rs +++ b/src/libextra/bitv.rs @@ -23,7 +23,7 @@ struct SmallBitv { } /// a mask that has a 1 for each defined bit in a small_bitv, assuming n bits -#[inline(always)] +#[inline(force)] fn small_mask(nbits: uint) -> uint { (1 << nbits) - 1 } @@ -33,7 +33,7 @@ impl SmallBitv { SmallBitv {bits: bits} } - #[inline(always)] + #[inline] pub fn bits_op(&mut self, right_bits: uint, nbits: uint, @@ -46,32 +46,32 @@ impl SmallBitv { mask & old_b != mask & new_b } - #[inline(always)] + #[inline] pub fn union(&mut self, s: &SmallBitv, nbits: uint) -> bool { self.bits_op(s.bits, nbits, |u1, u2| u1 | u2) } - #[inline(always)] + #[inline] pub fn intersect(&mut self, s: &SmallBitv, nbits: uint) -> bool { self.bits_op(s.bits, nbits, |u1, u2| u1 & u2) } - #[inline(always)] + #[inline] pub fn become(&mut self, s: &SmallBitv, nbits: uint) -> bool { self.bits_op(s.bits, nbits, |_u1, u2| u2) } - #[inline(always)] + #[inline] pub fn difference(&mut self, s: &SmallBitv, nbits: uint) -> bool { self.bits_op(s.bits, nbits, |u1, u2| u1 & !u2) } - #[inline(always)] + #[inline] pub fn get(&self, i: uint) -> bool { (self.bits & (1 << i)) != 0 } - #[inline(always)] + #[inline] pub fn set(&mut self, i: uint, x: bool) { if x { self.bits |= 1< bool { let mask = small_mask(nbits); mask & self.bits == mask & b.bits } - #[inline(always)] + #[inline] pub fn clear(&mut self) { self.bits = 0; } - #[inline(always)] + #[inline] pub fn set_all(&mut self) { self.bits = !0; } - #[inline(always)] + #[inline] pub fn is_true(&self, nbits: uint) -> bool { small_mask(nbits) & !self.bits == 0 } - #[inline(always)] + #[inline] pub fn is_false(&self, nbits: uint) -> bool { small_mask(nbits) & self.bits == 0 } - #[inline(always)] + #[inline] pub fn invert(&mut self) { self.bits = !self.bits; } } @@ -115,7 +115,7 @@ struct BigBitv { * a mask that has a 1 for each defined bit in the nth element of a big_bitv, * assuming n bits. */ -#[inline(always)] +#[inline] fn big_mask(nbits: uint, elem: uint) -> uint { let rmd = nbits % uint::bits; let nelems = nbits/uint::bits + if rmd == 0 {0} else {1}; @@ -132,7 +132,7 @@ impl BigBitv { BigBitv {storage: storage} } - #[inline(always)] + #[inline] pub fn process(&mut self, b: &BigBitv, nbits: uint, @@ -154,35 +154,35 @@ impl BigBitv { changed } - #[inline(always)] + #[inline] pub fn each_storage(&mut self, op: &fn(v: &mut uint) -> bool) -> bool { uint::range(0, self.storage.len(), |i| op(&mut self.storage[i])) } - #[inline(always)] + #[inline] pub fn invert(&mut self) { for self.each_storage |w| { *w = !*w } } - #[inline(always)] + #[inline] pub fn union(&mut self, b: &BigBitv, nbits: uint) -> bool { self.process(b, nbits, |w1, w2| w1 | w2) } - #[inline(always)] + #[inline] pub fn intersect(&mut self, b: &BigBitv, nbits: uint) -> bool { self.process(b, nbits, |w1, w2| w1 & w2) } - #[inline(always)] + #[inline] pub fn become(&mut self, b: &BigBitv, nbits: uint) -> bool { self.process(b, nbits, |_, w| w) } - #[inline(always)] + #[inline] pub fn difference(&mut self, b: &BigBitv, nbits: uint) -> bool { self.process(b, nbits, |w1, w2| w1 & !w2) } - #[inline(always)] + #[inline] pub fn get(&self, i: uint) -> bool { let w = i / uint::bits; let b = i % uint::bits; @@ -190,7 +190,7 @@ impl BigBitv { x == 1 } - #[inline(always)] + #[inline] pub fn set(&mut self, i: uint, x: bool) { let w = i / uint::bits; let b = i % uint::bits; @@ -199,7 +199,7 @@ impl BigBitv { else { self.storage[w] & !flag }; } - #[inline(always)] + #[inline] pub fn equals(&self, b: &BigBitv, nbits: uint) -> bool { let len = b.storage.len(); for uint::iterate(0, len) |i| { @@ -229,7 +229,7 @@ fn die() -> ! { } impl Bitv { - #[inline(always)] + #[inline] fn do_op(&mut self, op: Op, other: &Bitv) -> bool { if self.nbits != other.nbits { die(); @@ -279,7 +279,7 @@ impl Bitv { * Sets `self` to the union of `self` and `v1`. Both bitvectors must be * the same length. Returns 'true' if `self` changed. */ - #[inline(always)] + #[inline] pub fn union(&mut self, v1: &Bitv) -> bool { self.do_op(Union, v1) } /** @@ -288,7 +288,7 @@ impl Bitv { * Sets `self` to the intersection of `self` and `v1`. Both bitvectors * must be the same length. Returns 'true' if `self` changed. */ - #[inline(always)] + #[inline] pub fn intersect(&mut self, v1: &Bitv) -> bool { self.do_op(Intersect, v1) } @@ -299,11 +299,11 @@ impl Bitv { * Both bitvectors must be the same length. Returns `true` if `self` was * changed */ - #[inline(always)] + #[inline] pub fn assign(&mut self, v: &Bitv) -> bool { self.do_op(Assign, v) } /// Retrieve the value at index `i` - #[inline(always)] + #[inline] pub fn get(&self, i: uint) -> bool { assert!((i < self.nbits)); match self.rep { @@ -317,7 +317,7 @@ impl Bitv { * * `i` must be less than the length of the bitvector. */ - #[inline(always)] + #[inline] pub fn set(&mut self, i: uint, x: bool) { assert!((i < self.nbits)); match self.rep { @@ -332,7 +332,7 @@ impl Bitv { * Both bitvectors must be the same length. Returns `true` if both * bitvectors contain identical elements. */ - #[inline(always)] + #[inline] pub fn equal(&self, v1: &Bitv) -> bool { if self.nbits != v1.nbits { return false; } match self.rep { @@ -348,7 +348,7 @@ impl Bitv { } /// Set all bits to 0 - #[inline(always)] + #[inline] pub fn clear(&mut self) { match self.rep { Small(ref mut b) => b.clear(), @@ -357,7 +357,7 @@ impl Bitv { } /// Set all bits to 1 - #[inline(always)] + #[inline] pub fn set_all(&mut self) { match self.rep { Small(ref mut b) => b.set_all(), @@ -365,7 +365,7 @@ impl Bitv { } /// Invert all bits - #[inline(always)] + #[inline] pub fn invert(&mut self) { match self.rep { Small(ref mut b) => b.invert(), @@ -381,13 +381,13 @@ impl Bitv { * * Returns `true` if `v0` was changed. */ - #[inline(always)] + #[inline] pub fn difference(&mut self, v: &Bitv) -> bool { self.do_op(Difference, v) } /// Returns true if all bits are 1 - #[inline(always)] + #[inline] pub fn is_true(&self) -> bool { match self.rep { Small(ref b) => b.is_true(self.nbits), @@ -398,7 +398,7 @@ impl Bitv { } } - #[inline(always)] + #[inline] pub fn each(&self, f: &fn(bool) -> bool) -> bool { let mut i = 0; while i < self.nbits { @@ -508,7 +508,7 @@ impl Bitv { impl Clone for Bitv { /// Makes a copy of a bitvector - #[inline(always)] + #[inline] fn clone(&self) -> Bitv { match self.rep { Small(ref b) => { @@ -548,6 +548,7 @@ pub fn from_bools(bools: &[bool]) -> Bitv { * Create a bitv of the specified length where the value at each * index is f(index). */ +#[inline(force)] pub fn from_fn(len: uint, f: &fn(index: uint) -> bool) -> Bitv { let mut bitv = Bitv::new(len, false); for uint::range(0, len) |i| { @@ -562,7 +563,7 @@ impl ops::Index for Bitv { } } -#[inline(always)] +#[inline(force)] fn iterate_bits(base: uint, bits: uint, f: &fn(uint) -> bool) -> bool { if bits == 0 { return true; @@ -623,7 +624,7 @@ impl BitvSet { return Bitv{ nbits:cap, rep: Big(~bitv) }; } - #[inline(always)] + #[inline] fn other_op(&mut self, other: &BitvSet, f: &fn(uint, uint) -> uint) { fn nbits(mut w: uint) -> uint { let mut bits = 0; diff --git a/src/libextra/dlist.rs b/src/libextra/dlist.rs index 52e2b75d6b6d3..1ea3f6e2661fe 100644 --- a/src/libextra/dlist.rs +++ b/src/libextra/dlist.rs @@ -159,7 +159,7 @@ impl DList { } // Link two nodes together. If either of them are 'none', also sets // the head and/or tail pointers appropriately. - #[inline(always)] + #[inline] fn link(&mut self, before: DListLink, after: DListLink) { match before { Some(neighbour) => neighbour.next = after, @@ -531,7 +531,7 @@ impl BaseIter for @mut DList { return true; } - #[inline(always)] + #[inline] fn size_hint(&self) -> Option { Some(self.len()) } } diff --git a/src/libextra/num/rational.rs b/src/libextra/num/rational.rs index 1a8ab75b3dd0d..efdec63a6b91a 100644 --- a/src/libextra/num/rational.rs +++ b/src/libextra/num/rational.rs @@ -38,19 +38,19 @@ pub type BigRational = Ratio; impl Ratio { /// Create a ratio representing the integer `t`. - #[inline(always)] + #[inline] pub fn from_integer(t: T) -> Ratio { Ratio::new_raw(t, One::one()) } /// Create a ratio without checking for `denom == 0` or reducing. - #[inline(always)] + #[inline] pub fn new_raw(numer: T, denom: T) -> Ratio { Ratio { numer: numer, denom: denom } } /// Create a new Ratio. Fails if `denom == 0`. - #[inline(always)] + #[inline] pub fn new(numer: T, denom: T) -> Ratio { if denom == Zero::zero() { fail!("denominator == 0"); @@ -208,7 +208,7 @@ impl } } - #[inline(always)] + #[inline] fn round(&self) -> Ratio { if *self < Zero::zero() { Ratio::from_integer((self.numer - self.denom + One::one()) / self.denom) @@ -217,7 +217,7 @@ impl } } - #[inline(always)] + #[inline] fn trunc(&self) -> Ratio { Ratio::from_integer(self.numer / self.denom) } diff --git a/src/libextra/rc.rs b/src/libextra/rc.rs index 96ad629ea8374..709af1e4c652e 100644 --- a/src/libextra/rc.rs +++ b/src/libextra/rc.rs @@ -60,7 +60,7 @@ pub fn rc_from_const(value: T) -> Rc { } impl Rc { - #[inline(always)] + #[inline(force)] pub fn borrow<'r>(&'r self) -> &'r T { unsafe { cast::copy_lifetime(self, &(*self.ptr).value) } } diff --git a/src/libextra/semver.rs b/src/libextra/semver.rs index 494f0c8ea815f..04b807dc1b593 100644 --- a/src/libextra/semver.rs +++ b/src/libextra/semver.rs @@ -30,7 +30,7 @@ pub enum Identifier { } impl cmp::Ord for Identifier { - #[inline(always)] + #[inline(force)] fn lt(&self, other: &Identifier) -> bool { match (self, other) { (&Numeric(a), &Numeric(b)) => a < b, @@ -39,22 +39,22 @@ impl cmp::Ord for Identifier { (&AlphaNumeric(_), _) => false } } - #[inline(always)] + #[inline(force)] fn le(&self, other: &Identifier) -> bool { ! (other < self) } - #[inline(always)] + #[inline(force)] fn gt(&self, other: &Identifier) -> bool { other < self } - #[inline(always)] + #[inline(force)] fn ge(&self, other: &Identifier) -> bool { ! (self < other) } } impl ToStr for Identifier { - #[inline(always)] + #[inline(force)] fn to_str(&self) -> ~str { match self { &Numeric(n) => n.to_str(), @@ -74,7 +74,7 @@ pub struct Version { } impl ToStr for Version { - #[inline(always)] + #[inline(force)] fn to_str(&self) -> ~str { let s = fmt!("%u.%u.%u", self.major, self.minor, self.patch); let s = if self.pre.is_empty() { @@ -91,7 +91,7 @@ impl ToStr for Version { } impl cmp::Ord for Version { - #[inline(always)] + #[inline(force)] fn lt(&self, other: &Version) -> bool { self.major < other.major || @@ -124,15 +124,15 @@ impl cmp::Ord for Version { self.build < other.build) } - #[inline(always)] + #[inline(force)] fn le(&self, other: &Version) -> bool { ! (other < self) } - #[inline(always)] + #[inline(force)] fn gt(&self, other: &Version) -> bool { other < self } - #[inline(always)] + #[inline(force)] fn ge(&self, other: &Version) -> bool { ! (self < other) } diff --git a/src/libextra/sort.rs b/src/libextra/sort.rs index 420c63efab5d3..dc9101d90217c 100644 --- a/src/libextra/sort.rs +++ b/src/libextra/sort.rs @@ -725,7 +725,7 @@ impl MergeState { } } -#[inline(always)] +#[inline] fn copy_vec(dest: &mut [T], s1: uint, from: &[T]) { @@ -736,7 +736,7 @@ fn copy_vec(dest: &mut [T], } } -#[inline(always)] +#[inline] fn shift_vec(dest: &mut [T], s1: uint, s2: uint, diff --git a/src/libextra/sync.rs b/src/libextra/sync.rs index 28a5e5382be58..f80ebfbd01c7b 100644 --- a/src/libextra/sync.rs +++ b/src/libextra/sync.rs @@ -335,7 +335,7 @@ impl<'self> Condvar<'self> { // Checks whether a condvar ID was out of bounds, and fails if so, or does // something else next on success. -#[inline(always)] +#[inline(force)] #[doc(hidden)] fn check_cvar_bounds(out_of_bounds: Option, id: uint, act: &str, blk: &fn() -> U) -> U { diff --git a/src/libextra/treemap.rs b/src/libextra/treemap.rs index ebb0cdc120fbb..b2af75ca3c111 100644 --- a/src/libextra/treemap.rs +++ b/src/libextra/treemap.rs @@ -76,13 +76,13 @@ fn lt(a: &TreeMap, } impl Ord for TreeMap { - #[inline(always)] + #[inline(force)] fn lt(&self, other: &TreeMap) -> bool { lt(self, other) } - #[inline(always)] + #[inline(force)] fn le(&self, other: &TreeMap) -> bool { !lt(other, self) } - #[inline(always)] + #[inline(force)] fn ge(&self, other: &TreeMap) -> bool { !lt(self, other) } - #[inline(always)] + #[inline(force)] fn gt(&self, other: &TreeMap) -> bool { lt(other, self) } } @@ -146,7 +146,7 @@ impl Map for TreeMap { } /// Return a mutable reference to the value corresponding to the key - #[inline(always)] + #[inline(force)] fn find_mut<'a>(&'a mut self, key: &K) -> Option<&'a mut V> { find_mut(&mut self.root, key) } @@ -237,7 +237,7 @@ impl<'self, K, V> Iterator<(&'self K, &'self V)> for TreeMapIterator<'self, K, V impl<'self, T> Iterator<&'self T> for TreeSetIterator<'self, T> { /// Advance the iterator to the next node (in order). If there are no more nodes, return `None`. - #[inline(always)] + #[inline(force)] fn next(&mut self) -> Option<&'self T> { do self.iter.next().map |&(value, _)| { value } } @@ -252,69 +252,69 @@ pub struct TreeSet { impl BaseIter for TreeSet { /// Visit all values in order - #[inline(always)] + #[inline(force)] fn each(&self, f: &fn(&T) -> bool) -> bool { self.map.each_key(f) } - #[inline(always)] + #[inline] fn size_hint(&self) -> Option { Some(self.len()) } } impl ReverseIter for TreeSet { /// Visit all values in reverse order - #[inline(always)] + #[inline(force)] fn each_reverse(&self, f: &fn(&T) -> bool) -> bool { self.map.each_key_reverse(f) } } impl Eq for TreeSet { - #[inline(always)] + #[inline(force)] fn eq(&self, other: &TreeSet) -> bool { self.map == other.map } - #[inline(always)] + #[inline(force)] fn ne(&self, other: &TreeSet) -> bool { self.map != other.map } } impl Ord for TreeSet { - #[inline(always)] + #[inline(force)] fn lt(&self, other: &TreeSet) -> bool { self.map < other.map } - #[inline(always)] + #[inline(force)] fn le(&self, other: &TreeSet) -> bool { self.map <= other.map } - #[inline(always)] + #[inline(force)] fn ge(&self, other: &TreeSet) -> bool { self.map >= other.map } - #[inline(always)] + #[inline(force)] fn gt(&self, other: &TreeSet) -> bool { self.map > other.map } } impl Container for TreeSet { /// Return the number of elements in the set - #[inline(always)] + #[inline] fn len(&const self) -> uint { self.map.len() } /// Return true if the set contains no elements - #[inline(always)] + #[inline] fn is_empty(&const self) -> bool { self.map.is_empty() } } impl Mutable for TreeSet { /// Clear the set, removing all values. - #[inline(always)] + #[inline(force)] fn clear(&mut self) { self.map.clear() } } impl Set for TreeSet { /// Return true if the set contains a value - #[inline(always)] + #[inline] fn contains(&self, value: &T) -> bool { self.map.contains_key(value) } /// Add a value to the set. Return true if the value was not already /// present in the set. - #[inline(always)] + #[inline] fn insert(&mut self, value: T) -> bool { self.map.insert(value, ()) } /// Remove a value from the set. Return true if the value was /// present in the set. - #[inline(always)] + #[inline] fn remove(&mut self, value: &T) -> bool { self.map.remove(value) } /// Return true if the set has no elements in common with `other`. @@ -337,7 +337,7 @@ impl Set for TreeSet { } /// Return true if the set is a subset of another - #[inline(always)] + #[inline] fn is_subset(&self, other: &TreeSet) -> bool { other.is_superset(self) } @@ -491,12 +491,12 @@ impl Set for TreeSet { impl TreeSet { /// Create an empty TreeSet - #[inline(always)] + #[inline] pub fn new() -> TreeSet { TreeSet{map: TreeMap::new()} } /// Get a lazy iterator over the values in the set. /// Requires that it be frozen (immutable). - #[inline(always)] + #[inline] pub fn iter<'a>(&'a self) -> TreeSetIterator<'a, T> { TreeSetIterator{iter: self.map.iter()} } @@ -519,7 +519,7 @@ struct TreeNode { impl TreeNode { /// Creates a new tree node. - #[inline(always)] + #[inline] pub fn new(key: K, value: V) -> TreeNode { TreeNode{key: key, value: value, left: None, right: None, level: 1} } diff --git a/src/libextra/workcache.rs b/src/libextra/workcache.rs index b2fd998b73fd2..af8826fc6353e 100644 --- a/src/libextra/workcache.rs +++ b/src/libextra/workcache.rs @@ -104,7 +104,7 @@ struct WorkKey { } impl to_bytes::IterBytes for WorkKey { - #[inline(always)] + #[inline(force)] fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) -> bool { self.kind.iter_bytes(lsb0, f) && self.name.iter_bytes(lsb0, f) } diff --git a/src/librustc/back/passes.rs b/src/librustc/back/passes.rs index 315bb5d63177f..8fa69d594edc0 100644 --- a/src/librustc/back/passes.rs +++ b/src/librustc/back/passes.rs @@ -221,7 +221,7 @@ pub static analysis_passes : &'static [(&'static str, &'static str)] = &'static /** Transformation Passes */ pub static transform_passes : &'static [(&'static str, &'static str)] = &'static [ ("adce", "Aggressive Dead Code Elimination"), - ("always-inline", "Inliner for #[inline(always)] functions"), + ("always-inline", "Inliner for #[inline(force)] functions"), ("argpromotion", "Promote 'by reference' arguments to scalars"), ("bb-vectorize", "Basic-Block Vectorization"), ("block-placement", "Profile Guided Basic Block Placement"), diff --git a/src/librustc/metadata/encoder.rs b/src/librustc/metadata/encoder.rs index c696aacb44980..ef506e3063b51 100644 --- a/src/librustc/metadata/encoder.rs +++ b/src/librustc/metadata/encoder.rs @@ -762,7 +762,7 @@ fn purity_static_method_family(p: purity) -> char { fn should_inline(attrs: &[attribute]) -> bool { match attr::find_inline_attr(attrs) { attr::ia_none | attr::ia_never => false, - attr::ia_hint | attr::ia_always => true + attr::ia_hint | attr::ia_always | attr::ia_force => true } } diff --git a/src/librustc/middle/borrowck/mod.rs b/src/librustc/middle/borrowck/mod.rs index fa3bae3f5ac92..6e1ffe0754f41 100644 --- a/src/librustc/middle/borrowck/mod.rs +++ b/src/librustc/middle/borrowck/mod.rs @@ -776,17 +776,17 @@ impl BorrowckCtxt { } impl DataFlowOperator for LoanDataFlowOperator { - #[inline(always)] + #[inline] fn initial_value(&self) -> bool { false // no loans in scope by default } - #[inline(always)] + #[inline] fn join(&self, succ: uint, pred: uint) -> uint { succ | pred // loans from both preds are in scope } - #[inline(always)] + #[inline] fn walk_closures(&self) -> bool { true } diff --git a/src/librustc/middle/borrowck/move_data.rs b/src/librustc/middle/borrowck/move_data.rs index 2443c19ac97c5..a153c8e5bb4c1 100644 --- a/src/librustc/middle/borrowck/move_data.rs +++ b/src/librustc/middle/borrowck/move_data.rs @@ -571,34 +571,34 @@ impl FlowedMoveData { } impl DataFlowOperator for MoveDataFlowOperator { - #[inline(always)] + #[inline] fn initial_value(&self) -> bool { false // no loans in scope by default } - #[inline(always)] + #[inline] fn join(&self, succ: uint, pred: uint) -> uint { succ | pred // moves from both preds are in scope } - #[inline(always)] + #[inline] fn walk_closures(&self) -> bool { true } } impl DataFlowOperator for AssignDataFlowOperator { - #[inline(always)] + #[inline] fn initial_value(&self) -> bool { false // no assignments in scope by default } - #[inline(always)] + #[inline] fn join(&self, succ: uint, pred: uint) -> uint { succ | pred // moves from both preds are in scope } - #[inline(always)] + #[inline] fn walk_closures(&self) -> bool { true } diff --git a/src/librustc/middle/dataflow.rs b/src/librustc/middle/dataflow.rs index 349deef2998c6..63ec163afe9c5 100644 --- a/src/librustc/middle/dataflow.rs +++ b/src/librustc/middle/dataflow.rs @@ -966,7 +966,7 @@ fn join_bits(oper: &O, bitwise(out_vec, in_vec, |a, b| oper.join(a, b)) } -#[inline(always)] +#[inline] fn bitwise(out_vec: &mut [uint], in_vec: &[uint], op: &fn(uint, uint) -> uint) -> bool { diff --git a/src/librustc/middle/trans/adt.rs b/src/librustc/middle/trans/adt.rs index b26f80fc355b1..23c6dcdaf04f4 100644 --- a/src/librustc/middle/trans/adt.rs +++ b/src/librustc/middle/trans/adt.rs @@ -574,7 +574,7 @@ fn padding(size: u64) -> ValueRef { } // XXX this utility routine should be somewhere more general -#[inline(always)] +#[inline] fn roundup(x: u64, a: u64) -> u64 { ((x + (a - 1)) / a) * a } /// Get the discriminant of a constant value. (Not currently used.) diff --git a/src/librustc/middle/trans/base.rs b/src/librustc/middle/trans/base.rs index 2d1dd34af4ad0..fde625ce56365 100644 --- a/src/librustc/middle/trans/base.rs +++ b/src/librustc/middle/trans/base.rs @@ -452,11 +452,27 @@ pub fn set_inline_hint(f: ValueRef) { } } -pub fn set_inline_hint_if_appr(attrs: &[ast::attribute], +pub fn set_inline_hint_if_appr(ccx: &CrateContext, + attrs: &[ast::attribute], llfn: ValueRef) { match attr::find_inline_attr(attrs) { attr::ia_hint => set_inline_hint(llfn), - attr::ia_always => set_always_inline(llfn), + attr::ia_always => { + for attrs.each |a| { + match a.node.value.node { + ast::meta_list(@~"inline", ref items) => { + if !attr::find_meta_items_by_name(*items, "always").is_empty() { + ccx.sess.span_warn(a.span, + "`#[inline(always)]` is deprecated, \ + use `#[inline]` or `#[inline(force)]` instead"); + set_always_inline(llfn); + } + } + _ => () + } + } + } + attr::ia_force => set_always_inline(llfn), attr::ia_never => set_no_inline(llfn), attr::ia_none => { /* fallthrough */ } } @@ -2470,7 +2486,7 @@ pub fn get_item_val(ccx: @CrateContext, id: ast::node_id) -> ValueRef { i.id, i.attrs) }; - set_inline_hint_if_appr(i.attrs, llfn); + set_inline_hint_if_appr(ccx, i.attrs, llfn); llfn } _ => fail!("get_item_val: weird result in table") @@ -2582,7 +2598,7 @@ pub fn register_method(ccx: @CrateContext, let pth = vec::append(/*bad*/copy *pth, [path_name((ccx.names)("meth")), path_name(m.ident)]); let llfn = register_fn_full(ccx, m.span, pth, id, m.attrs, mty); - set_inline_hint_if_appr(m.attrs, llfn); + set_inline_hint_if_appr(ccx, m.attrs, llfn); llfn } diff --git a/src/librustc/middle/trans/monomorphize.rs b/src/librustc/middle/trans/monomorphize.rs index 062f72b6feba6..720bbdaf028be 100644 --- a/src/librustc/middle/trans/monomorphize.rs +++ b/src/librustc/middle/trans/monomorphize.rs @@ -194,7 +194,7 @@ pub fn monomorphic_fn(ccx: @CrateContext, _ }, _) => { let d = mk_lldecl(); - set_inline_hint_if_appr(/*bad*/copy i.attrs, d); + set_inline_hint_if_appr(ccx, i.attrs, d); trans_fn(ccx, pt, decl, @@ -234,7 +234,7 @@ pub fn monomorphic_fn(ccx: @CrateContext, ast_map::node_method(mth, supplied_impl_did, _) => { // XXX: What should the self type be here? let d = mk_lldecl(); - set_inline_hint_if_appr(/*bad*/copy mth.attrs, d); + set_inline_hint_if_appr(ccx, mth.attrs, d); // Override the impl def ID if necessary. let impl_did; @@ -248,7 +248,7 @@ pub fn monomorphic_fn(ccx: @CrateContext, } ast_map::node_trait_method(@ast::provided(mth), _, pt) => { let d = mk_lldecl(); - set_inline_hint_if_appr(/*bad*/copy mth.attrs, d); + set_inline_hint_if_appr(ccx, mth.attrs, d); debug!("monomorphic_fn impl_did_opt is %?", impl_did_opt); meth::trans_method(ccx, /*bad*/copy *pt, mth, psubsts, None, d, impl_did_opt.get()); diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs index 8e2691c8a27a1..d49daac349de7 100644 --- a/src/librustc/middle/ty.rs +++ b/src/librustc/middle/ty.rs @@ -1091,62 +1091,62 @@ fn mk_t(cx: ctxt, st: sty) -> t { } } -#[inline(always)] +#[inline(force)] pub fn mk_prim_t(primitive: &'static t_box_) -> t { unsafe { cast::transmute::<&'static t_box_, t>(primitive) } } -#[inline(always)] +#[inline(force)] pub fn mk_nil() -> t { mk_prim_t(&primitives::TY_NIL) } -#[inline(always)] +#[inline(force)] pub fn mk_err() -> t { mk_prim_t(&primitives::TY_ERR) } -#[inline(always)] +#[inline(force)] pub fn mk_bot() -> t { mk_prim_t(&primitives::TY_BOT) } -#[inline(always)] +#[inline(force)] pub fn mk_bool() -> t { mk_prim_t(&primitives::TY_BOOL) } -#[inline(always)] +#[inline(force)] pub fn mk_int() -> t { mk_prim_t(&primitives::TY_INT) } -#[inline(always)] +#[inline(force)] pub fn mk_i8() -> t { mk_prim_t(&primitives::TY_I8) } -#[inline(always)] +#[inline(force)] pub fn mk_i16() -> t { mk_prim_t(&primitives::TY_I16) } -#[inline(always)] +#[inline(force)] pub fn mk_i32() -> t { mk_prim_t(&primitives::TY_I32) } -#[inline(always)] +#[inline(force)] pub fn mk_i64() -> t { mk_prim_t(&primitives::TY_I64) } -#[inline(always)] +#[inline(force)] pub fn mk_float() -> t { mk_prim_t(&primitives::TY_FLOAT) } -#[inline(always)] +#[inline(force)] pub fn mk_f32() -> t { mk_prim_t(&primitives::TY_F32) } -#[inline(always)] +#[inline(force)] pub fn mk_f64() -> t { mk_prim_t(&primitives::TY_F64) } -#[inline(always)] +#[inline(force)] pub fn mk_uint() -> t { mk_prim_t(&primitives::TY_UINT) } -#[inline(always)] +#[inline(force)] pub fn mk_u8() -> t { mk_prim_t(&primitives::TY_U8) } -#[inline(always)] +#[inline(force)] pub fn mk_u16() -> t { mk_prim_t(&primitives::TY_U16) } -#[inline(always)] +#[inline(force)] pub fn mk_u32() -> t { mk_prim_t(&primitives::TY_U32) } -#[inline(always)] +#[inline(force)] pub fn mk_u64() -> t { mk_prim_t(&primitives::TY_U64) } pub fn mk_mach_int(tm: ast::int_ty) -> t { @@ -1178,7 +1178,7 @@ pub fn mk_mach_float(tm: ast::float_ty) -> t { } } -#[inline(always)] +#[inline(force)] pub fn mk_char() -> t { mk_prim_t(&primitives::TY_CHAR) } pub fn mk_estr(cx: ctxt, t: vstore) -> t { diff --git a/src/librustc/middle/typeck/check/mod.rs b/src/librustc/middle/typeck/check/mod.rs index c69aeeb4aa8b8..3e3493ea7e687 100644 --- a/src/librustc/middle/typeck/check/mod.rs +++ b/src/librustc/middle/typeck/check/mod.rs @@ -730,7 +730,7 @@ impl FnCtxt { ty::re_scope(self.region_lb) } - #[inline(always)] + #[inline] pub fn write_ty(&self, node_id: ast::node_id, ty: ty::t) { debug!("write_ty(%d, %s) in fcx %s", node_id, ppaux::ty_to_str(self.tcx(), ty), self.tag()); diff --git a/src/libstd/at_vec.rs b/src/libstd/at_vec.rs index 23f901c23ed2d..8a06c1c854054 100644 --- a/src/libstd/at_vec.rs +++ b/src/libstd/at_vec.rs @@ -38,7 +38,7 @@ pub mod rustrt { } /// Returns the number of elements the vector can hold without reallocating -#[inline(always)] +#[inline] pub fn capacity(v: @[T]) -> uint { unsafe { let repr: **raw::VecRepr = transmute(&v); @@ -58,7 +58,7 @@ pub fn capacity(v: @[T]) -> uint { * as an argument a function that will push an element * onto the vector being constructed. */ -#[inline(always)] +#[inline] pub fn build_sized(size: uint, builder: &fn(push: &fn(v: A))) -> @[A] { let mut vec: @[A] = @[]; unsafe { raw::reserve(&mut vec, size); } @@ -76,7 +76,7 @@ pub fn build_sized(size: uint, builder: &fn(push: &fn(v: A))) -> @[A] { * as an argument a function that will push an element * onto the vector being constructed. */ -#[inline(always)] +#[inline] pub fn build(builder: &fn(push: &fn(v: A))) -> @[A] { build_sized(4, builder) } @@ -93,7 +93,7 @@ pub fn build(builder: &fn(push: &fn(v: A))) -> @[A] { * as an argument a function that will push an element * onto the vector being constructed. */ -#[inline(always)] +#[inline] pub fn build_sized_opt(size: Option, builder: &fn(push: &fn(v: A))) -> @[A] { @@ -104,7 +104,7 @@ pub fn build_sized_opt(size: Option, /// Iterates over the `rhs` vector, copying each element and appending it to the /// `lhs`. Afterwards, the `lhs` is then returned for use again. -#[inline(always)] +#[inline] pub fn append(lhs: @[T], rhs: &const [T]) -> @[T] { do build_sized(lhs.len() + rhs.len()) |push| { for lhs.each |x| { push(*x); } @@ -178,7 +178,7 @@ pub mod traits { use ops::Add; impl<'self,T:Copy> Add<&'self const [T],@[T]> for @[T] { - #[inline(always)] + #[inline] fn add(&self, rhs: & &'self const [T]) -> @[T] { append(*self, (*rhs)) } @@ -208,7 +208,7 @@ pub mod raw { * modifing its buffers, so it is up to the caller to ensure that * the vector is actually the specified size. */ - #[inline(always)] + #[inline] pub unsafe fn set_len(v: @[T], new_len: uint) { let repr: **mut VecRepr = transmute(&v); (**repr).unboxed.fill = new_len * sys::size_of::(); @@ -217,7 +217,7 @@ pub mod raw { /** * Pushes a new value onto this vector. */ - #[inline(always)] + #[inline] pub unsafe fn push(v: &mut @[T], initval: T) { let repr: **VecRepr = transmute_copy(&v); let fill = (**repr).unboxed.fill; @@ -228,7 +228,7 @@ pub mod raw { } } - #[inline(always)] // really pretty please + #[inline(force)] unsafe fn push_fast(v: &mut @[T], initval: T) { let repr: **mut VecRepr = ::cast::transmute(v); let fill = (**repr).unboxed.fill; diff --git a/src/libstd/bool.rs b/src/libstd/bool.rs index 66a5bfa944f10..e6be164099bf0 100644 --- a/src/libstd/bool.rs +++ b/src/libstd/bool.rs @@ -212,7 +212,7 @@ impl FromStr for bool { * ~~~ */ impl ToStr for bool { - #[inline(always)] + #[inline] fn to_str(&self) -> ~str { if *self { ~"true" } else { ~"false" } } @@ -250,24 +250,24 @@ pub fn all_values(blk: &fn(v: bool)) { * 0 * ~~~ */ -#[inline(always)] +#[inline] pub fn to_bit(v: bool) -> u8 { if v { 1u8 } else { 0u8 } } #[cfg(not(test))] impl Ord for bool { - #[inline(always)] + #[inline] fn lt(&self, other: &bool) -> bool { to_bit(*self) < to_bit(*other) } - #[inline(always)] + #[inline] fn le(&self, other: &bool) -> bool { to_bit(*self) <= to_bit(*other) } - #[inline(always)] + #[inline] fn gt(&self, other: &bool) -> bool { to_bit(*self) > to_bit(*other) } - #[inline(always)] + #[inline] fn ge(&self, other: &bool) -> bool { to_bit(*self) >= to_bit(*other) } } #[cfg(not(test))] impl TotalOrd for bool { - #[inline(always)] + #[inline] fn cmp(&self, other: &bool) -> Ordering { to_bit(*self).cmp(&to_bit(*other)) } } @@ -298,9 +298,9 @@ impl TotalOrd for bool { */ #[cfg(not(test))] impl Eq for bool { - #[inline(always)] + #[inline] fn eq(&self, other: &bool) -> bool { (*self) == (*other) } - #[inline(always)] + #[inline] fn ne(&self, other: &bool) -> bool { (*self) != (*other) } } diff --git a/src/libstd/borrow.rs b/src/libstd/borrow.rs index 703011aea7f86..9e3a3a28fe8ce 100644 --- a/src/libstd/borrow.rs +++ b/src/libstd/borrow.rs @@ -14,13 +14,13 @@ use prelude::*; /// Cast a region pointer - &T - to a uint. -#[inline(always)] +#[inline] pub fn to_uint(thing: &T) -> uint { thing as *T as uint } /// Determine if two borrowed pointers point to the same thing. -#[inline(always)] +#[inline] pub fn ref_eq<'a, 'b, T>(thing: &'a T, other: &'b T) -> bool { to_uint(thing) == to_uint(other) } @@ -28,11 +28,11 @@ pub fn ref_eq<'a, 'b, T>(thing: &'a T, other: &'b T) -> bool { // Equality for region pointers #[cfg(not(test))] impl<'self, T: Eq> Eq for &'self T { - #[inline(always)] + #[inline] fn eq(&self, other: & &'self T) -> bool { *(*self) == *(*other) } - #[inline(always)] + #[inline] fn ne(&self, other: & &'self T) -> bool { *(*self) != *(*other) } @@ -41,19 +41,19 @@ impl<'self, T: Eq> Eq for &'self T { // Comparison for region pointers #[cfg(not(test))] impl<'self, T: Ord> Ord for &'self T { - #[inline(always)] + #[inline] fn lt(&self, other: & &'self T) -> bool { *(*self) < *(*other) } - #[inline(always)] + #[inline] fn le(&self, other: & &'self T) -> bool { *(*self) <= *(*other) } - #[inline(always)] + #[inline] fn ge(&self, other: & &'self T) -> bool { *(*self) >= *(*other) } - #[inline(always)] + #[inline] fn gt(&self, other: & &'self T) -> bool { *(*self) > *(*other) } diff --git a/src/libstd/cast.rs b/src/libstd/cast.rs index 2109568a0a4e0..c878a4d9fb49b 100644 --- a/src/libstd/cast.rs +++ b/src/libstd/cast.rs @@ -29,7 +29,7 @@ pub unsafe fn transmute_copy(src: &T) -> U { /// Casts the value at `src` to U. The two types must have the same length. #[cfg(target_word_size = "32", not(stage0))] -#[inline(always)] +#[inline] pub unsafe fn transmute_copy(src: &T) -> U { let mut dest: U = intrinsics::uninit(); let dest_ptr: *mut u8 = transmute(&mut dest); @@ -40,7 +40,7 @@ pub unsafe fn transmute_copy(src: &T) -> U { /// Casts the value at `src` to U. The two types must have the same length. #[cfg(target_word_size = "64", not(stage0))] -#[inline(always)] +#[inline] pub unsafe fn transmute_copy(src: &T) -> U { let mut dest: U = intrinsics::uninit(); let dest_ptr: *mut u8 = transmute(&mut dest); @@ -57,7 +57,7 @@ pub unsafe fn transmute_copy(src: &T) -> U { * can be used for various acts of magick, particularly when using * reinterpret_cast on pointer types. */ -#[inline(always)] +#[inline] pub unsafe fn forget(thing: T) { intrinsics::forget(thing); } /** @@ -66,7 +66,7 @@ pub unsafe fn forget(thing: T) { intrinsics::forget(thing); } * and/or reinterpret_cast when such calls would otherwise scramble a box's * reference count */ -#[inline(always)] +#[inline] pub unsafe fn bump_box_refcount(t: @T) { forget(t); } /** @@ -77,59 +77,59 @@ pub unsafe fn bump_box_refcount(t: @T) { forget(t); } * * assert!(transmute("L") == ~[76u8, 0u8]); */ -#[inline(always)] +#[inline] pub unsafe fn transmute(thing: L) -> G { intrinsics::transmute(thing) } /// Coerce an immutable reference to be mutable. -#[inline(always)] +#[inline] pub unsafe fn transmute_mut<'a,T>(ptr: &'a T) -> &'a mut T { transmute(ptr) } /// Coerce a mutable reference to be immutable. -#[inline(always)] +#[inline] pub unsafe fn transmute_immut<'a,T>(ptr: &'a mut T) -> &'a T { transmute(ptr) } /// Coerce a borrowed pointer to have an arbitrary associated region. -#[inline(always)] +#[inline] pub unsafe fn transmute_region<'a,'b,T>(ptr: &'a T) -> &'b T { transmute(ptr) } /// Coerce an immutable reference to be mutable. -#[inline(always)] +#[inline] pub unsafe fn transmute_mut_unsafe(ptr: *const T) -> *mut T { transmute(ptr) } /// Coerce an immutable reference to be mutable. -#[inline(always)] +#[inline] pub unsafe fn transmute_immut_unsafe(ptr: *const T) -> *T { transmute(ptr) } /// Coerce a borrowed mutable pointer to have an arbitrary associated region. -#[inline(always)] +#[inline] pub unsafe fn transmute_mut_region<'a,'b,T>(ptr: &'a mut T) -> &'b mut T { transmute(ptr) } /// Transforms lifetime of the second pointer to match the first. -#[inline(always)] +#[inline] pub unsafe fn copy_lifetime<'a,S,T>(_ptr: &'a S, ptr: &T) -> &'a T { transmute_region(ptr) } /// Transforms lifetime of the second pointer to match the first. -#[inline(always)] +#[inline] pub unsafe fn copy_mut_lifetime<'a,S,T>(_ptr: &'a mut S, ptr: &mut T) -> &'a mut T { transmute_mut_region(ptr) } /// Transforms lifetime of the second pointer to match the first. -#[inline(always)] +#[inline] pub unsafe fn copy_lifetime_vec<'a,S,T>(_ptr: &'a [S], ptr: &T) -> &'a T { transmute_region(ptr) } diff --git a/src/libstd/char.rs b/src/libstd/char.rs index 073ced8988ada..336e6d8b2d87a 100644 --- a/src/libstd/char.rs +++ b/src/libstd/char.rs @@ -65,14 +65,14 @@ pub fn is_XID_continue(c: char) -> bool { derived_property::XID_Continue(c) } /// Indicates whether a character is in lower case, defined /// in terms of the Unicode General Category 'Ll' /// -#[inline(always)] +#[inline] pub fn is_lowercase(c: char) -> bool { general_category::Ll(c) } /// /// Indicates whether a character is in upper case, defined /// in terms of the Unicode General Category 'Lu'. /// -#[inline(always)] +#[inline] pub fn is_uppercase(c: char) -> bool { general_category::Lu(c) } /// @@ -80,7 +80,7 @@ pub fn is_uppercase(c: char) -> bool { general_category::Lu(c) } /// terms of the Unicode General Categories 'Zs', 'Zl', 'Zp' /// additional 'Cc'-category control codes in the range [0x09, 0x0d] /// -#[inline(always)] +#[inline] pub fn is_whitespace(c: char) -> bool { ('\x09' <= c && c <= '\x0d') || general_category::Zs(c) @@ -93,7 +93,7 @@ pub fn is_whitespace(c: char) -> bool { /// defined in terms of the Unicode General Categories 'Nd', 'Nl', 'No' /// and the Derived Core Property 'Alphabetic'. /// -#[inline(always)] +#[inline] pub fn is_alphanumeric(c: char) -> bool { derived_property::Alphabetic(c) || general_category::Nd(c) @@ -102,7 +102,7 @@ pub fn is_alphanumeric(c: char) -> bool { } /// Indicates whether the character is numeric (Nd, Nl, or No) -#[inline(always)] +#[inline] pub fn is_digit(c: char) -> bool { general_category::Nd(c) || general_category::Nl(c) @@ -127,7 +127,7 @@ pub fn is_digit(c: char) -> bool { /// /// This just wraps `to_digit()`. /// -#[inline(always)] +#[inline] pub fn is_digit_radix(c: char, radix: uint) -> bool { match to_digit(c, radix) { Some(_) => true, @@ -310,21 +310,21 @@ impl Char for char { #[cfg(not(test))] impl Eq for char { - #[inline(always)] + #[inline] fn eq(&self, other: &char) -> bool { (*self) == (*other) } - #[inline(always)] + #[inline] fn ne(&self, other: &char) -> bool { (*self) != (*other) } } #[cfg(not(test))] impl Ord for char { - #[inline(always)] + #[inline] fn lt(&self, other: &char) -> bool { *self < *other } - #[inline(always)] + #[inline] fn le(&self, other: &char) -> bool { *self <= *other } - #[inline(always)] + #[inline] fn gt(&self, other: &char) -> bool { *self > *other } - #[inline(always)] + #[inline] fn ge(&self, other: &char) -> bool { *self >= *other } } diff --git a/src/libstd/clone.rs b/src/libstd/clone.rs index 266dd1a35e32c..5ec594cef7ee6 100644 --- a/src/libstd/clone.rs +++ b/src/libstd/clone.rs @@ -34,25 +34,25 @@ pub trait Clone { impl Clone for ~T { /// Return a deep copy of the owned box. - #[inline(always)] + #[inline] fn clone(&self) -> ~T { ~(**self).clone() } } impl Clone for @T { /// Return a shallow copy of the managed box. - #[inline(always)] + #[inline] fn clone(&self) -> @T { *self } } impl Clone for @mut T { /// Return a shallow copy of the managed box. - #[inline(always)] + #[inline] fn clone(&self) -> @mut T { *self } } impl<'self, T> Clone for &'self T { /// Return a shallow copy of the borrowed pointer. - #[inline(always)] + #[inline] fn clone(&self) -> &'self T { *self } } @@ -60,7 +60,7 @@ macro_rules! clone_impl( ($t:ty) => { impl Clone for $t { /// Return a deep copy of the value. - #[inline(always)] + #[inline] fn clone(&self) -> $t { *self } } } @@ -96,7 +96,7 @@ pub trait DeepClone { impl DeepClone for ~T { /// Return a deep copy of the owned box. - #[inline(always)] + #[inline] fn deep_clone(&self) -> ~T { ~(**self).deep_clone() } } @@ -104,7 +104,7 @@ impl DeepClone for ~T { impl DeepClone for @T { /// Return a deep copy of the managed box. The `Const` trait is required to prevent performing /// a deep clone of a potentially cyclical type. - #[inline(always)] + #[inline] fn deep_clone(&self) -> @T { @(**self).deep_clone() } } @@ -112,7 +112,7 @@ impl DeepClone for @T { impl DeepClone for @mut T { /// Return a deep copy of the managed box. The `Const` trait is required to prevent performing /// a deep clone of a potentially cyclical type. - #[inline(always)] + #[inline] fn deep_clone(&self) -> @mut T { @mut (**self).deep_clone() } } @@ -120,7 +120,7 @@ macro_rules! deep_clone_impl( ($t:ty) => { impl DeepClone for $t { /// Return a deep copy of the value. - #[inline(always)] + #[inline] fn deep_clone(&self) -> $t { *self } } } diff --git a/src/libstd/cmp.rs b/src/libstd/cmp.rs index 55530f181a11b..42634df76ca3a 100644 --- a/src/libstd/cmp.rs +++ b/src/libstd/cmp.rs @@ -45,7 +45,7 @@ pub trait TotalEq { macro_rules! totaleq_impl( ($t:ty) => { impl TotalEq for $t { - #[inline(always)] + #[inline] fn equals(&self, other: &$t) -> bool { *self == *other } } } @@ -84,27 +84,27 @@ pub trait TotalOrd: TotalEq { } impl TotalOrd for Ordering { - #[inline(always)] + #[inline] fn cmp(&self, other: &Ordering) -> Ordering { (*self as int).cmp(&(*other as int)) } } impl Ord for Ordering { - #[inline(always)] + #[inline] fn lt(&self, other: &Ordering) -> bool { (*self as int) < (*other as int) } - #[inline(always)] + #[inline] fn le(&self, other: &Ordering) -> bool { (*self as int) <= (*other as int) } - #[inline(always)] + #[inline] fn gt(&self, other: &Ordering) -> bool { (*self as int) > (*other as int) } - #[inline(always)] + #[inline] fn ge(&self, other: &Ordering) -> bool { (*self as int) >= (*other as int) } } macro_rules! totalord_impl( ($t:ty) => { impl TotalOrd for $t { - #[inline(always)] + #[inline] fn cmp(&self, other: &$t) -> Ordering { if *self < *other { Less } else if *self > *other { Greater } @@ -146,7 +146,7 @@ Return `o1` if it is not `Equal`, otherwise `o2`. Simulates the lexical ordering on a type `(int, int)`. */ // used in deriving code in libsyntax -#[inline(always)] +#[inline] pub fn lexical_ordering(o1: Ordering, o2: Ordering) -> Ordering { match o1 { Equal => o2, @@ -172,32 +172,32 @@ pub trait Ord { fn gt(&self, other: &Self) -> bool; } -#[inline(always)] +#[inline] pub fn lt(v1: &T, v2: &T) -> bool { (*v1).lt(v2) } -#[inline(always)] +#[inline] pub fn le(v1: &T, v2: &T) -> bool { (*v1).le(v2) } -#[inline(always)] +#[inline] pub fn eq(v1: &T, v2: &T) -> bool { (*v1).eq(v2) } -#[inline(always)] +#[inline] pub fn ne(v1: &T, v2: &T) -> bool { (*v1).ne(v2) } -#[inline(always)] +#[inline] pub fn ge(v1: &T, v2: &T) -> bool { (*v1).ge(v2) } -#[inline(always)] +#[inline] pub fn gt(v1: &T, v2: &T) -> bool { (*v1).gt(v2) } @@ -210,12 +210,12 @@ pub trait Equiv { fn equiv(&self, other: &T) -> bool; } -#[inline(always)] +#[inline] pub fn min(v1: T, v2: T) -> T { if v1 < v2 { v1 } else { v2 } } -#[inline(always)] +#[inline] pub fn max(v1: T, v2: T) -> T { if v1 > v2 { v1 } else { v2 } } diff --git a/src/libstd/comm.rs b/src/libstd/comm.rs index f0c353c8d62b6..f02a2345f5fd0 100644 --- a/src/libstd/comm.rs +++ b/src/libstd/comm.rs @@ -625,7 +625,7 @@ mod pipesy { } impl GenericChan for Chan { - #[inline(always)] + #[inline] fn send(&self, x: T) { unsafe { let self_endp = transmute_mut(&self.endp); @@ -636,7 +636,7 @@ mod pipesy { } impl GenericSmartChan for Chan { - #[inline(always)] + #[inline] fn try_send(&self, x: T) -> bool { unsafe { let self_endp = transmute_mut(&self.endp); @@ -653,7 +653,7 @@ mod pipesy { } impl GenericPort for Port { - #[inline(always)] + #[inline] fn recv(&self) -> T { unsafe { let self_endp = transmute_mut(&self.endp); @@ -664,7 +664,7 @@ mod pipesy { } } - #[inline(always)] + #[inline] fn try_recv(&self) -> Option { unsafe { let self_endp = transmute_mut(&self.endp); @@ -681,7 +681,7 @@ mod pipesy { } impl Peekable for Port { - #[inline(always)] + #[inline] fn peek(&self) -> bool { unsafe { let self_endp = transmute_mut(&self.endp); diff --git a/src/libstd/either.rs b/src/libstd/either.rs index fac0866f17e76..af3a55b534730 100644 --- a/src/libstd/either.rs +++ b/src/libstd/either.rs @@ -33,7 +33,7 @@ pub enum Either { /// If `value` is left(T) then `f_left` is applied to its contents, if /// `value` is right(U) then `f_right` is applied to its contents, and the /// result is returned. -#[inline(always)] +#[inline] pub fn either(f_left: &fn(&T) -> V, f_right: &fn(&U) -> V, value: &Either) -> V { match *value { @@ -83,7 +83,7 @@ pub fn partition(eithers: ~[Either]) -> (~[T], ~[U]) { } /// Flips between left and right of a given either -#[inline(always)] +#[inline] pub fn flip(eith: Either) -> Either { match eith { Right(r) => Left(r), @@ -95,7 +95,7 @@ pub fn flip(eith: Either) -> Either { /// /// Converts an `either` type to a `result` type, making the "right" choice /// an ok result, and the "left" choice a fail -#[inline(always)] +#[inline] pub fn to_result(eith: Either) -> Result { match eith { Right(r) => result::Ok(r), @@ -104,7 +104,7 @@ pub fn to_result(eith: Either) -> Result { } /// Checks whether the given value is a left -#[inline(always)] +#[inline] pub fn is_left(eith: &Either) -> bool { match *eith { Left(_) => true, @@ -113,7 +113,7 @@ pub fn is_left(eith: &Either) -> bool { } /// Checks whether the given value is a right -#[inline(always)] +#[inline] pub fn is_right(eith: &Either) -> bool { match *eith { Right(_) => true, @@ -122,7 +122,7 @@ pub fn is_right(eith: &Either) -> bool { } /// Retrieves the value in the left branch. Fails if the either is Right. -#[inline(always)] +#[inline] pub fn unwrap_left(eith: Either) -> T { match eith { Left(x) => x, @@ -131,7 +131,7 @@ pub fn unwrap_left(eith: Either) -> T { } /// Retrieves the value in the right branch. Fails if the either is Left. -#[inline(always)] +#[inline] pub fn unwrap_right(eith: Either) -> U { match eith { Right(x) => x, @@ -140,27 +140,27 @@ pub fn unwrap_right(eith: Either) -> U { } impl Either { - #[inline(always)] + #[inline] pub fn either(&self, f_left: &fn(&T) -> V, f_right: &fn(&U) -> V) -> V { either(f_left, f_right, self) } - #[inline(always)] + #[inline] pub fn flip(self) -> Either { flip(self) } - #[inline(always)] + #[inline] pub fn to_result(self) -> Result { to_result(self) } - #[inline(always)] + #[inline] pub fn is_left(&self) -> bool { is_left(self) } - #[inline(always)] + #[inline] pub fn is_right(&self) -> bool { is_right(self) } - #[inline(always)] + #[inline] pub fn unwrap_left(self) -> T { unwrap_left(self) } - #[inline(always)] + #[inline] pub fn unwrap_right(self) -> U { unwrap_right(self) } } diff --git a/src/libstd/hash.rs b/src/libstd/hash.rs index e902244578634..60d79854ed217 100644 --- a/src/libstd/hash.rs +++ b/src/libstd/hash.rs @@ -64,7 +64,7 @@ pub trait HashUtil { } impl HashUtil for A { - #[inline(always)] + #[inline] fn hash(&self) -> u64 { self.hash_keyed(0,0) } } @@ -79,7 +79,7 @@ pub trait Streaming { } impl Hash for A { - #[inline(always)] + #[inline] fn hash_keyed(&self, k0: u64, k1: u64) -> u64 { let mut s = State::new(k0, k1); for self.iter_bytes(true) |bytes| { @@ -176,7 +176,7 @@ fn hash_keyed_5 State { State::new(0, 0) } @@ -194,7 +194,7 @@ struct SipState { } impl SipState { - #[inline(always)] + #[inline] fn new(key0: u64, key1: u64) -> SipState { let mut state = SipState { k0: key0, @@ -248,7 +248,7 @@ macro_rules! compress ( impl Writer for SipState { // Methods for io::writer - #[inline(always)] + #[inline] fn write(&mut self, msg: &[u8]) { let length = msg.len(); self.length += length; @@ -315,12 +315,12 @@ impl Writer for SipState { } impl Streaming for SipState { - #[inline(always)] + #[inline] fn input(&mut self, buf: &[u8]) { self.write(buf); } - #[inline(always)] + #[inline] fn result_u64(&mut self) -> u64 { let mut v0 = self.v0; let mut v1 = self.v1; @@ -373,7 +373,7 @@ impl Streaming for SipState { s } - #[inline(always)] + #[inline] fn reset(&mut self) { self.length = 0; self.v0 = self.k0 ^ 0x736f6d6570736575; diff --git a/src/libstd/hashmap.rs b/src/libstd/hashmap.rs index b1400d1bc76f4..87d831bcb9a50 100644 --- a/src/libstd/hashmap.rs +++ b/src/libstd/hashmap.rs @@ -58,7 +58,7 @@ enum SearchResult { FoundEntry(uint), FoundHole(uint), TableFull } -#[inline(always)] +#[inline] fn resize_at(capacity: uint) -> uint { ((capacity as float) * 3. / 4.) as uint } @@ -84,21 +84,21 @@ fn linear_map_with_capacity_and_keys( } impl HashMap { - #[inline(always)] + #[inline] fn to_bucket(&self, h: uint) -> uint { // A good hash function with entropy spread over all of the // bits is assumed. SipHash is more than good enough. h % self.buckets.len() } - #[inline(always)] + #[inline] fn next_bucket(&self, idx: uint, len_buckets: uint) -> uint { let n = (idx + 1) % len_buckets; debug!("next_bucket(%?, %?) = %?", idx, len_buckets, n); n } - #[inline(always)] + #[inline] fn bucket_sequence(&self, hash: uint, op: &fn(uint) -> bool) -> bool { let start_idx = self.to_bucket(hash); @@ -113,20 +113,20 @@ impl HashMap { } } - #[inline(always)] + #[inline] fn bucket_for_key(&self, k: &K) -> SearchResult { let hash = k.hash_keyed(self.k0, self.k1) as uint; self.bucket_for_key_with_hash(hash, k) } - #[inline(always)] + #[inline] fn bucket_for_key_equiv>(&self, k: &Q) -> SearchResult { let hash = k.hash_keyed(self.k0, self.k1) as uint; self.bucket_for_key_with_hash_equiv(hash, k) } - #[inline(always)] + #[inline] fn bucket_for_key_with_hash(&self, hash: uint, k: &K) @@ -142,7 +142,7 @@ impl HashMap { TableFull } - #[inline(always)] + #[inline] fn bucket_for_key_with_hash_equiv>(&self, hash: uint, k: &Q) @@ -162,7 +162,7 @@ impl HashMap { /// Expand the capacity of the array to the next power of two /// and re-insert each of the existing buckets. - #[inline(always)] + #[inline] fn expand(&mut self) { let new_capacity = self.buckets.len() * 2; self.resize(new_capacity); @@ -191,7 +191,7 @@ impl HashMap { } } - #[inline(always)] + #[inline] fn value_for_bucket<'a>(&'a self, idx: uint) -> &'a V { match self.buckets[idx] { Some(ref bkt) => &bkt.value, @@ -199,7 +199,7 @@ impl HashMap { } } - #[inline(always)] + #[inline] fn mut_value_for_bucket<'a>(&'a mut self, idx: uint) -> &'a mut V { match self.buckets[idx] { Some(ref mut bkt) => &mut bkt.value, diff --git a/src/libstd/iter.rs b/src/libstd/iter.rs index 8a0ec3ade4d4e..970a9d3017471 100644 --- a/src/libstd/iter.rs +++ b/src/libstd/iter.rs @@ -76,7 +76,7 @@ pub trait FromIter { * assert!(!any(|&x: &uint| x > 5, |f| xs.each(f))); * ~~~ */ -#[inline(always)] +#[inline(force)] pub fn any(predicate: &fn(T) -> bool, iter: &fn(f: &fn(T) -> bool) -> bool) -> bool { for iter |x| { @@ -97,7 +97,7 @@ pub fn any(predicate: &fn(T) -> bool, * assert!(!all(|&x: &uint| x < 5, |f| uint::range(1, 6, f))); * ~~~ */ -#[inline(always)] +#[inline(force)] pub fn all(predicate: &fn(T) -> bool, iter: &fn(f: &fn(T) -> bool) -> bool) -> bool { // If we ever break, iter will return false, so this will only return true @@ -115,7 +115,7 @@ pub fn all(predicate: &fn(T) -> bool, * assert_eq!(*find(|& &x: & &uint| x > 3, |f| xs.each(f)).unwrap(), 4); * ~~~ */ -#[inline(always)] +#[inline(force)] pub fn find(predicate: &fn(&T) -> bool, iter: &fn(f: &fn(T) -> bool) -> bool) -> Option { for iter |x| { @@ -229,7 +229,7 @@ pub fn fold_ref(start: T, iter: &fn(f: &fn(&U) -> bool) -> bool, f: &fn(&m * assert_eq!(do sum |f| { xs.each(f) }, 10); * ~~~ */ -#[inline(always)] +#[inline(force)] pub fn sum>(iter: &fn(f: &fn(&T) -> bool) -> bool) -> T { fold_ref(Zero::zero::(), iter, |a, x| *a = a.add(x)) } @@ -244,7 +244,7 @@ pub fn sum>(iter: &fn(f: &fn(&T) -> bool) -> bool) -> T { * assert_eq!(do product |f| { xs.each(f) }, 24); * ~~~ */ -#[inline(always)] +#[inline(force)] pub fn product>(iter: &fn(f: &fn(&T) -> bool) -> bool) -> T { fold_ref(One::one::(), iter, |a, x| *a = a.mul(x)) } diff --git a/src/libstd/iterator.rs b/src/libstd/iterator.rs index 7f723e44c2b05..dc1b6102dc396 100644 --- a/src/libstd/iterator.rs +++ b/src/libstd/iterator.rs @@ -348,58 +348,58 @@ pub trait IteratorUtil { /// /// In the future these will be default methods instead of a utility trait. impl> IteratorUtil for T { - #[inline(always)] + #[inline(force)] fn chain>(self, other: U) -> ChainIterator { ChainIterator{a: self, b: other, flag: false} } - #[inline(always)] + #[inline(force)] fn zip>(self, other: U) -> ZipIterator { ZipIterator{a: self, b: other} } // FIXME: #5898: should be called map - #[inline(always)] + #[inline(force)] fn transform<'r, B>(self, f: &'r fn(A) -> B) -> MapIterator<'r, A, B, T> { MapIterator{iter: self, f: f} } - #[inline(always)] + #[inline(force)] fn filter<'r>(self, predicate: &'r fn(&A) -> bool) -> FilterIterator<'r, A, T> { FilterIterator{iter: self, predicate: predicate} } - #[inline(always)] + #[inline(force)] fn filter_map<'r, B>(self, f: &'r fn(A) -> Option) -> FilterMapIterator<'r, A, B, T> { FilterMapIterator { iter: self, f: f } } - #[inline(always)] + #[inline(force)] fn enumerate(self) -> EnumerateIterator { EnumerateIterator{iter: self, count: 0} } - #[inline(always)] + #[inline(force)] fn skip_while<'r>(self, predicate: &'r fn(&A) -> bool) -> SkipWhileIterator<'r, A, T> { SkipWhileIterator{iter: self, flag: false, predicate: predicate} } - #[inline(always)] + #[inline(force)] fn take_while<'r>(self, predicate: &'r fn(&A) -> bool) -> TakeWhileIterator<'r, A, T> { TakeWhileIterator{iter: self, flag: false, predicate: predicate} } - #[inline(always)] + #[inline(force)] fn skip(self, n: uint) -> SkipIterator { SkipIterator{iter: self, n: n} } - #[inline(always)] + #[inline(force)] fn take(self, n: uint) -> TakeIterator { TakeIterator{iter: self, n: n} } - #[inline(always)] + #[inline(force)] fn scan<'r, St, B>(self, initial_state: St, f: &'r fn(&mut St, A) -> Option) -> ScanIterator<'r, A, B, T, St> { ScanIterator{iter: self, f: f, state: initial_state} @@ -418,13 +418,13 @@ impl> IteratorUtil for T { } } - #[inline(always)] + #[inline(force)] fn collect>(&mut self) -> B { FromIter::from_iter::(|f| self.advance(f)) } /// Return the `n`th item yielded by an iterator. - #[inline(always)] + #[inline(force)] fn nth(&mut self, mut n: uint) -> Option { loop { match self.next() { @@ -436,7 +436,7 @@ impl> IteratorUtil for T { } /// Return the last item yielded by an iterator. - #[inline(always)] + #[inline(force)] fn last(&mut self) -> Option { let mut last = None; for self.advance |x| { last = Some(x); } @@ -457,16 +457,16 @@ impl> IteratorUtil for T { } /// Count the number of items yielded by an iterator - #[inline(always)] + #[inline(force)] fn count(&mut self) -> uint { self.fold(0, |cnt, _x| cnt + 1) } - #[inline(always)] + #[inline(force)] fn all(&mut self, f: &fn(&A) -> bool) -> bool { for self.advance |x| { if !f(&x) { return false; } } return true; } - #[inline(always)] + #[inline(force)] fn any(&mut self, f: &fn(&A) -> bool) -> bool { for self.advance |x| { if f(&x) { return true; } } return false; @@ -490,7 +490,7 @@ pub trait AdditiveIterator { } impl + Zero, T: Iterator> AdditiveIterator for T { - #[inline(always)] + #[inline(force)] fn sum(&mut self) -> A { self.fold(Zero::zero::(), |s, x| s + x) } } @@ -515,7 +515,7 @@ pub trait MultiplicativeIterator { } impl + One, T: Iterator> MultiplicativeIterator for T { - #[inline(always)] + #[inline(force)] fn product(&mut self) -> A { self.fold(One::one::(), |p, x| p * x) } } @@ -548,7 +548,7 @@ pub trait OrdIterator { } impl> OrdIterator for T { - #[inline(always)] + #[inline(force)] fn max(&mut self) -> Option { self.fold(None, |max, x| { match max { @@ -558,7 +558,7 @@ impl> OrdIterator for T { }) } - #[inline(always)] + #[inline(force)] fn min(&mut self) -> Option { self.fold(None, |min, x| { match min { @@ -850,14 +850,14 @@ pub struct Counter { impl Counter { /// Creates a new counter with the specified start/step - #[inline(always)] + #[inline(force)] pub fn new(start: A, step: A) -> Counter { Counter{state: start, step: step} } } impl + Clone> Iterator for Counter { - #[inline(always)] + #[inline(force)] fn next(&mut self) -> Option { let result = self.state.clone(); self.state = self.state.add(&self.step); // FIXME: #6050 diff --git a/src/libstd/libc.rs b/src/libstd/libc.rs index 26205c930f0ca..812ce30ad5561 100644 --- a/src/libstd/libc.rs +++ b/src/libstd/libc.rs @@ -1457,11 +1457,11 @@ pub mod funcs { // These are fine to execute on the Rust stack. They must be, // in fact, because LLVM generates calls to them! #[rust_stack] - #[inline(always)] + #[inline(force)] unsafe fn memcmp(cx: *c_void, ct: *c_void, n: size_t) -> c_int; #[rust_stack] - #[inline(always)] + #[inline(force)] unsafe fn memchr(cx: *c_void, c: c_int, n: size_t) -> *c_void; } } diff --git a/src/libstd/managed.rs b/src/libstd/managed.rs index 7d0defea05ace..d514612b5afd8 100644 --- a/src/libstd/managed.rs +++ b/src/libstd/managed.rs @@ -38,14 +38,14 @@ pub mod raw { } /// Determine if two shared boxes point to the same object -#[inline(always)] +#[inline] pub fn ptr_eq(a: @T, b: @T) -> bool { let (a_ptr, b_ptr): (*T, *T) = (to_unsafe_ptr(&*a), to_unsafe_ptr(&*b)); a_ptr == b_ptr } /// Determine if two mutable shared boxes point to the same object -#[inline(always)] +#[inline] pub fn mut_ptr_eq(a: @mut T, b: @mut T) -> bool { let (a_ptr, b_ptr): (*T, *T) = (to_unsafe_ptr(&*a), to_unsafe_ptr(&*b)); a_ptr == b_ptr @@ -53,41 +53,41 @@ pub fn mut_ptr_eq(a: @mut T, b: @mut T) -> bool { #[cfg(not(test))] impl Eq for @T { - #[inline(always)] + #[inline] fn eq(&self, other: &@T) -> bool { *(*self) == *(*other) } - #[inline(always)] + #[inline] fn ne(&self, other: &@T) -> bool { *(*self) != *(*other) } } #[cfg(not(test))] impl Eq for @mut T { - #[inline(always)] + #[inline] fn eq(&self, other: &@mut T) -> bool { *(*self) == *(*other) } - #[inline(always)] + #[inline] fn ne(&self, other: &@mut T) -> bool { *(*self) != *(*other) } } #[cfg(not(test))] impl Ord for @T { - #[inline(always)] + #[inline] fn lt(&self, other: &@T) -> bool { *(*self) < *(*other) } - #[inline(always)] + #[inline] fn le(&self, other: &@T) -> bool { *(*self) <= *(*other) } - #[inline(always)] + #[inline] fn ge(&self, other: &@T) -> bool { *(*self) >= *(*other) } - #[inline(always)] + #[inline] fn gt(&self, other: &@T) -> bool { *(*self) > *(*other) } } #[cfg(not(test))] impl Ord for @mut T { - #[inline(always)] + #[inline] fn lt(&self, other: &@mut T) -> bool { *(*self) < *(*other) } - #[inline(always)] + #[inline] fn le(&self, other: &@mut T) -> bool { *(*self) <= *(*other) } - #[inline(always)] + #[inline] fn ge(&self, other: &@mut T) -> bool { *(*self) >= *(*other) } - #[inline(always)] + #[inline] fn gt(&self, other: &@mut T) -> bool { *(*self) > *(*other) } } diff --git a/src/libstd/nil.rs b/src/libstd/nil.rs index 833bd3459cebf..40f6d53ed22f0 100644 --- a/src/libstd/nil.rs +++ b/src/libstd/nil.rs @@ -19,32 +19,32 @@ use prelude::*; #[cfg(not(test))] impl Eq for () { - #[inline(always)] + #[inline] fn eq(&self, _other: &()) -> bool { true } - #[inline(always)] + #[inline] fn ne(&self, _other: &()) -> bool { false } } #[cfg(not(test))] impl Ord for () { - #[inline(always)] + #[inline] fn lt(&self, _other: &()) -> bool { false } - #[inline(always)] + #[inline] fn le(&self, _other: &()) -> bool { true } - #[inline(always)] + #[inline] fn ge(&self, _other: &()) -> bool { true } - #[inline(always)] + #[inline] fn gt(&self, _other: &()) -> bool { false } } #[cfg(not(test))] impl TotalOrd for () { - #[inline(always)] + #[inline] fn cmp(&self, _other: &()) -> Ordering { Equal } } #[cfg(not(test))] impl TotalEq for () { - #[inline(always)] + #[inline] fn equals(&self, _other: &()) -> bool { true } } diff --git a/src/libstd/num/f32.rs b/src/libstd/num/f32.rs index 62ce5ed65e10c..6614895a79a0e 100644 --- a/src/libstd/num/f32.rs +++ b/src/libstd/num/f32.rs @@ -20,7 +20,7 @@ use to_str; pub use cmath::c_float_targ_consts::*; -// An inner module is required to get the #[inline(always)] attribute on the +// An inner module is required to get the #[inline(force)] attribute on the // functions. pub use self::delegated::*; @@ -40,7 +40,7 @@ macro_rules! delegate( use unstable::intrinsics; $( - #[inline(always)] + #[inline(force)] pub fn $name($( $arg : $arg_ty ),*) -> $rv { unsafe { $bound_name($( $arg ),*) @@ -115,45 +115,45 @@ pub static infinity: f32 = 1.0_f32/0.0_f32; pub static neg_infinity: f32 = -1.0_f32/0.0_f32; -#[inline(always)] +#[inline(force)] pub fn add(x: f32, y: f32) -> f32 { return x + y; } -#[inline(always)] +#[inline(force)] pub fn sub(x: f32, y: f32) -> f32 { return x - y; } -#[inline(always)] +#[inline(force)] pub fn mul(x: f32, y: f32) -> f32 { return x * y; } -#[inline(always)] +#[inline(force)] pub fn div(x: f32, y: f32) -> f32 { return x / y; } -#[inline(always)] +#[inline(force)] pub fn rem(x: f32, y: f32) -> f32 { return x % y; } -#[inline(always)] +#[inline(force)] pub fn lt(x: f32, y: f32) -> bool { return x < y; } -#[inline(always)] +#[inline(force)] pub fn le(x: f32, y: f32) -> bool { return x <= y; } -#[inline(always)] +#[inline(force)] pub fn eq(x: f32, y: f32) -> bool { return x == y; } -#[inline(always)] +#[inline(force)] pub fn ne(x: f32, y: f32) -> bool { return x != y; } -#[inline(always)] +#[inline(force)] pub fn ge(x: f32, y: f32) -> bool { return x >= y; } -#[inline(always)] +#[inline(force)] pub fn gt(x: f32, y: f32) -> bool { return x > y; } -#[inline(always)] +#[inline(force)] pub fn fmax(x: f32, y: f32) -> f32 { if x >= y || y.is_NaN() { x } else { y } } -#[inline(always)] +#[inline(force)] pub fn fmin(x: f32, y: f32) -> f32 { if x <= y || y.is_NaN() { x } else { y } } @@ -167,8 +167,8 @@ pub fn fmin(x: f32, y: f32) -> f32 { /* Module: consts */ pub mod consts { // FIXME (requires Issue #1433 to fix): replace with mathematical - // staticants from cmath. - /// Archimedes' staticant + // constants from cmath. + /// Archimedes' constant pub static pi: f32 = 3.14159265358979323846264338327950288_f32; /// pi/2.0 @@ -212,23 +212,23 @@ impl Num for f32 {} #[cfg(not(test))] impl Eq for f32 { - #[inline(always)] + #[inline(force)] fn eq(&self, other: &f32) -> bool { (*self) == (*other) } - #[inline(always)] + #[inline(force)] fn ne(&self, other: &f32) -> bool { (*self) != (*other) } } #[cfg(not(test))] impl ApproxEq for f32 { - #[inline(always)] + #[inline(force)] fn approx_epsilon() -> f32 { 1.0e-6 } - #[inline(always)] + #[inline(force)] fn approx_eq(&self, other: &f32) -> bool { self.approx_eq_eps(other, &ApproxEq::approx_epsilon::()) } - #[inline(always)] + #[inline(force)] fn approx_eq_eps(&self, other: &f32, approx_epsilon: &f32) -> bool { (*self - *other).abs() < *approx_epsilon } @@ -236,32 +236,32 @@ impl ApproxEq for f32 { #[cfg(not(test))] impl Ord for f32 { - #[inline(always)] + #[inline(force)] fn lt(&self, other: &f32) -> bool { (*self) < (*other) } - #[inline(always)] + #[inline(force)] fn le(&self, other: &f32) -> bool { (*self) <= (*other) } - #[inline(always)] + #[inline(force)] fn ge(&self, other: &f32) -> bool { (*self) >= (*other) } - #[inline(always)] + #[inline(force)] fn gt(&self, other: &f32) -> bool { (*self) > (*other) } } impl Orderable for f32 { /// Returns `NaN` if either of the numbers are `NaN`. - #[inline(always)] + #[inline(force)] fn min(&self, other: &f32) -> f32 { if self.is_NaN() || other.is_NaN() { Float::NaN() } else { fmin(*self, *other) } } /// Returns `NaN` if either of the numbers are `NaN`. - #[inline(always)] + #[inline(force)] fn max(&self, other: &f32) -> f32 { if self.is_NaN() || other.is_NaN() { Float::NaN() } else { fmax(*self, *other) } } /// Returns the number constrained within the range `mn <= self <= mx`. /// If any of the numbers are `NaN` then `NaN` is returned. - #[inline(always)] + #[inline(force)] fn clamp(&self, mn: &f32, mx: &f32) -> f32 { cond!( (self.is_NaN()) { *self } @@ -273,65 +273,65 @@ impl Orderable for f32 { } impl Zero for f32 { - #[inline(always)] + #[inline(force)] fn zero() -> f32 { 0.0 } /// Returns true if the number is equal to either `0.0` or `-0.0` - #[inline(always)] + #[inline(force)] fn is_zero(&self) -> bool { *self == 0.0 || *self == -0.0 } } impl One for f32 { - #[inline(always)] + #[inline(force)] fn one() -> f32 { 1.0 } } #[cfg(not(test))] impl Add for f32 { - #[inline(always)] + #[inline(force)] fn add(&self, other: &f32) -> f32 { *self + *other } } #[cfg(not(test))] impl Sub for f32 { - #[inline(always)] + #[inline(force)] fn sub(&self, other: &f32) -> f32 { *self - *other } } #[cfg(not(test))] impl Mul for f32 { - #[inline(always)] + #[inline(force)] fn mul(&self, other: &f32) -> f32 { *self * *other } } #[cfg(not(test))] impl Div for f32 { - #[inline(always)] + #[inline(force)] fn div(&self, other: &f32) -> f32 { *self / *other } } #[cfg(not(test))] impl Rem for f32 { - #[inline(always)] + #[inline(force)] fn rem(&self, other: &f32) -> f32 { *self % *other } } #[cfg(not(test))] impl Neg for f32 { - #[inline(always)] + #[inline(force)] fn neg(&self) -> f32 { -*self } } impl Signed for f32 { /// Computes the absolute value. Returns `NaN` if the number is `NaN`. - #[inline(always)] + #[inline(force)] fn abs(&self) -> f32 { abs(*self) } /// /// The positive difference of two numbers. Returns `0.0` if the number is less than or /// equal to `other`, otherwise the difference between`self` and `other` is returned. /// - #[inline(always)] + #[inline(force)] fn abs_sub(&self, other: &f32) -> f32 { abs_sub(*self, *other) } /// @@ -341,35 +341,35 @@ impl Signed for f32 { /// - `-1.0` if the number is negative, `-0.0` or `neg_infinity` /// - `NaN` if the number is NaN /// - #[inline(always)] + #[inline(force)] fn signum(&self) -> f32 { if self.is_NaN() { NaN } else { copysign(1.0, *self) } } /// Returns `true` if the number is positive, including `+0.0` and `infinity` - #[inline(always)] + #[inline(force)] fn is_positive(&self) -> bool { *self > 0.0 || (1.0 / *self) == infinity } /// Returns `true` if the number is negative, including `-0.0` and `neg_infinity` - #[inline(always)] + #[inline(force)] fn is_negative(&self) -> bool { *self < 0.0 || (1.0 / *self) == neg_infinity } } impl Round for f32 { /// Round half-way cases toward `neg_infinity` - #[inline(always)] + #[inline(force)] fn floor(&self) -> f32 { floor(*self) } /// Round half-way cases toward `infinity` - #[inline(always)] + #[inline(force)] fn ceil(&self) -> f32 { ceil(*self) } /// Round half-way cases away from `0.0` - #[inline(always)] + #[inline(force)] fn round(&self) -> f32 { round(*self) } /// The integer part of the number (rounds towards `0.0`) - #[inline(always)] + #[inline(force)] fn trunc(&self) -> f32 { trunc(*self) } /// @@ -379,57 +379,57 @@ impl Round for f32 { /// assert!(x == trunc(x) + fract(x)) /// ~~~ /// - #[inline(always)] + #[inline(force)] fn fract(&self) -> f32 { *self - self.trunc() } } impl Fractional for f32 { /// The reciprocal (multiplicative inverse) of the number - #[inline(always)] + #[inline(force)] fn recip(&self) -> f32 { 1.0 / *self } } impl Algebraic for f32 { - #[inline(always)] + #[inline(force)] fn pow(&self, n: f32) -> f32 { pow(*self, n) } - #[inline(always)] + #[inline(force)] fn sqrt(&self) -> f32 { sqrt(*self) } - #[inline(always)] + #[inline(force)] fn rsqrt(&self) -> f32 { self.sqrt().recip() } - #[inline(always)] + #[inline(force)] fn cbrt(&self) -> f32 { cbrt(*self) } - #[inline(always)] + #[inline(force)] fn hypot(&self, other: f32) -> f32 { hypot(*self, other) } } impl Trigonometric for f32 { - #[inline(always)] + #[inline(force)] fn sin(&self) -> f32 { sin(*self) } - #[inline(always)] + #[inline(force)] fn cos(&self) -> f32 { cos(*self) } - #[inline(always)] + #[inline(force)] fn tan(&self) -> f32 { tan(*self) } - #[inline(always)] + #[inline(force)] fn asin(&self) -> f32 { asin(*self) } - #[inline(always)] + #[inline(force)] fn acos(&self) -> f32 { acos(*self) } - #[inline(always)] + #[inline(force)] fn atan(&self) -> f32 { atan(*self) } - #[inline(always)] + #[inline(force)] fn atan2(&self, other: f32) -> f32 { atan2(*self, other) } /// Simultaneously computes the sine and cosine of the number - #[inline(always)] + #[inline(force)] fn sin_cos(&self) -> (f32, f32) { (self.sin(), self.cos()) } @@ -437,38 +437,38 @@ impl Trigonometric for f32 { impl Exponential for f32 { /// Returns the exponential of the number - #[inline(always)] + #[inline(force)] fn exp(&self) -> f32 { exp(*self) } /// Returns 2 raised to the power of the number - #[inline(always)] + #[inline(force)] fn exp2(&self) -> f32 { exp2(*self) } /// Returns the natural logarithm of the number - #[inline(always)] + #[inline(force)] fn ln(&self) -> f32 { ln(*self) } /// Returns the logarithm of the number with respect to an arbitrary base - #[inline(always)] + #[inline(force)] fn log(&self, base: f32) -> f32 { self.ln() / base.ln() } /// Returns the base 2 logarithm of the number - #[inline(always)] + #[inline(force)] fn log2(&self) -> f32 { log2(*self) } /// Returns the base 10 logarithm of the number - #[inline(always)] + #[inline(force)] fn log10(&self) -> f32 { log10(*self) } } impl Hyperbolic for f32 { - #[inline(always)] + #[inline(force)] fn sinh(&self) -> f32 { sinh(*self) } - #[inline(always)] + #[inline(force)] fn cosh(&self) -> f32 { cosh(*self) } - #[inline(always)] + #[inline(force)] fn tanh(&self) -> f32 { tanh(*self) } /// @@ -480,7 +480,7 @@ impl Hyperbolic for f32 { /// - `self` if `self` is `0.0`, `-0.0`, `infinity`, or `neg_infinity` /// - `NaN` if `self` is `NaN` /// - #[inline(always)] + #[inline(force)] fn asinh(&self) -> f32 { match *self { neg_infinity => neg_infinity, @@ -497,7 +497,7 @@ impl Hyperbolic for f32 { /// - `infinity` if `self` is `infinity` /// - `NaN` if `self` is `NaN` or `self < 1.0` (including `neg_infinity`) /// - #[inline(always)] + #[inline(force)] fn acosh(&self) -> f32 { match *self { x if x < 1.0 => Float::NaN(), @@ -517,7 +517,7 @@ impl Hyperbolic for f32 { /// - `NaN` if the `self` is `NaN` or outside the domain of `-1.0 <= self <= 1.0` /// (including `infinity` and `neg_infinity`) /// - #[inline(always)] + #[inline(force)] fn atanh(&self) -> f32 { 0.5 * ((2.0 * *self) / (1.0 - *self)).ln_1p() } @@ -525,129 +525,129 @@ impl Hyperbolic for f32 { impl Real for f32 { /// Archimedes' constant - #[inline(always)] + #[inline(force)] fn pi() -> f32 { 3.14159265358979323846264338327950288 } /// 2.0 * pi - #[inline(always)] + #[inline(force)] fn two_pi() -> f32 { 6.28318530717958647692528676655900576 } /// pi / 2.0 - #[inline(always)] + #[inline(force)] fn frac_pi_2() -> f32 { 1.57079632679489661923132169163975144 } /// pi / 3.0 - #[inline(always)] + #[inline(force)] fn frac_pi_3() -> f32 { 1.04719755119659774615421446109316763 } /// pi / 4.0 - #[inline(always)] + #[inline(force)] fn frac_pi_4() -> f32 { 0.785398163397448309615660845819875721 } /// pi / 6.0 - #[inline(always)] + #[inline(force)] fn frac_pi_6() -> f32 { 0.52359877559829887307710723054658381 } /// pi / 8.0 - #[inline(always)] + #[inline(force)] fn frac_pi_8() -> f32 { 0.39269908169872415480783042290993786 } /// 1 .0/ pi - #[inline(always)] + #[inline(force)] fn frac_1_pi() -> f32 { 0.318309886183790671537767526745028724 } /// 2.0 / pi - #[inline(always)] + #[inline(force)] fn frac_2_pi() -> f32 { 0.636619772367581343075535053490057448 } /// 2.0 / sqrt(pi) - #[inline(always)] + #[inline(force)] fn frac_2_sqrtpi() -> f32 { 1.12837916709551257389615890312154517 } /// sqrt(2.0) - #[inline(always)] + #[inline(force)] fn sqrt2() -> f32 { 1.41421356237309504880168872420969808 } /// 1.0 / sqrt(2.0) - #[inline(always)] + #[inline(force)] fn frac_1_sqrt2() -> f32 { 0.707106781186547524400844362104849039 } /// Euler's number - #[inline(always)] + #[inline(force)] fn e() -> f32 { 2.71828182845904523536028747135266250 } /// log2(e) - #[inline(always)] + #[inline(force)] fn log2_e() -> f32 { 1.44269504088896340735992468100189214 } /// log10(e) - #[inline(always)] + #[inline(force)] fn log10_e() -> f32 { 0.434294481903251827651128918916605082 } /// ln(2.0) - #[inline(always)] + #[inline(force)] fn ln_2() -> f32 { 0.693147180559945309417232121458176568 } /// ln(10.0) - #[inline(always)] + #[inline(force)] fn ln_10() -> f32 { 2.30258509299404568401799145468436421 } /// Converts to degrees, assuming the number is in radians - #[inline(always)] + #[inline(force)] fn to_degrees(&self) -> f32 { *self * (180.0 / Real::pi::()) } /// Converts to radians, assuming the number is in degrees - #[inline(always)] + #[inline(force)] fn to_radians(&self) -> f32 { *self * (Real::pi::() / 180.0) } } impl Bounded for f32 { - #[inline(always)] + #[inline(force)] fn min_value() -> f32 { 1.17549435e-38 } - #[inline(always)] + #[inline(force)] fn max_value() -> f32 { 3.40282347e+38 } } impl Primitive for f32 { - #[inline(always)] + #[inline(force)] fn bits() -> uint { 32 } - #[inline(always)] + #[inline(force)] fn bytes() -> uint { Primitive::bits::() / 8 } } impl Float for f32 { - #[inline(always)] + #[inline(force)] fn NaN() -> f32 { 0.0 / 0.0 } - #[inline(always)] + #[inline(force)] fn infinity() -> f32 { 1.0 / 0.0 } - #[inline(always)] + #[inline(force)] fn neg_infinity() -> f32 { -1.0 / 0.0 } - #[inline(always)] + #[inline(force)] fn neg_zero() -> f32 { -0.0 } /// Returns `true` if the number is NaN - #[inline(always)] + #[inline(force)] fn is_NaN(&self) -> bool { *self != *self } /// Returns `true` if the number is infinite - #[inline(always)] + #[inline(force)] fn is_infinite(&self) -> bool { *self == Float::infinity() || *self == Float::neg_infinity() } /// Returns `true` if the number is neither infinite or NaN - #[inline(always)] + #[inline(force)] fn is_finite(&self) -> bool { !(self.is_NaN() || self.is_infinite()) } /// Returns `true` if the number is neither zero, infinite, subnormal or NaN - #[inline(always)] + #[inline(force)] fn is_normal(&self) -> bool { self.classify() == FPNormal } @@ -670,29 +670,29 @@ impl Float for f32 { } } - #[inline(always)] + #[inline(force)] fn mantissa_digits() -> uint { 24 } - #[inline(always)] + #[inline(force)] fn digits() -> uint { 6 } - #[inline(always)] + #[inline(force)] fn epsilon() -> f32 { 1.19209290e-07 } - #[inline(always)] + #[inline(force)] fn min_exp() -> int { -125 } - #[inline(always)] + #[inline(force)] fn max_exp() -> int { 128 } - #[inline(always)] + #[inline(force)] fn min_10_exp() -> int { -37 } - #[inline(always)] + #[inline(force)] fn max_10_exp() -> int { 38 } /// Constructs a floating point number by multiplying `x` by 2 raised to the power of `exp` - #[inline(always)] + #[inline(force)] fn ldexp(x: f32, exp: int) -> f32 { ldexp(x, exp as c_int) } @@ -703,7 +703,7 @@ impl Float for f32 { /// - `self = x * pow(2, exp)` /// - `0.5 <= abs(x) < 1.0` /// - #[inline(always)] + #[inline(force)] fn frexp(&self) -> (f32, int) { let mut exp = 0; let x = frexp(*self, &mut exp); @@ -714,14 +714,14 @@ impl Float for f32 { /// Returns the exponential of the number, minus `1`, in a way that is accurate /// even if the number is close to zero /// - #[inline(always)] + #[inline(force)] fn exp_m1(&self) -> f32 { exp_m1(*self) } /// /// Returns the natural logarithm of the number plus `1` (`ln(1+n)`) more accurately /// than if the operations were performed separately /// - #[inline(always)] + #[inline(force)] fn ln_1p(&self) -> f32 { ln_1p(*self) } /// @@ -729,13 +729,13 @@ impl Float for f32 { /// produces a more accurate result with better performance than a separate multiplication /// operation followed by an add. /// - #[inline(always)] + #[inline(force)] fn mul_add(&self, a: f32, b: f32) -> f32 { mul_add(*self, a, b) } /// Returns the next representable floating-point value in the direction of `other` - #[inline(always)] + #[inline(force)] fn next_after(&self, other: f32) -> f32 { next_after(*self, other) } @@ -752,7 +752,7 @@ impl Float for f32 { /// /// * num - The float value /// -#[inline(always)] +#[inline] pub fn to_str(num: f32) -> ~str { let (r, _) = strconv::to_str_common( &num, 10u, true, strconv::SignNeg, strconv::DigAll); @@ -766,7 +766,7 @@ pub fn to_str(num: f32) -> ~str { /// /// * num - The float value /// -#[inline(always)] +#[inline] pub fn to_str_hex(num: f32) -> ~str { let (r, _) = strconv::to_str_common( &num, 16u, true, strconv::SignNeg, strconv::DigAll); @@ -787,7 +787,7 @@ pub fn to_str_hex(num: f32) -> ~str { /// possible misinterpretation of the result at higher bases. If those values /// are expected, use `to_str_radix_special()` instead. /// -#[inline(always)] +#[inline] pub fn to_str_radix(num: f32, rdx: uint) -> ~str { let (r, special) = strconv::to_str_common( &num, rdx, true, strconv::SignNeg, strconv::DigAll); @@ -805,7 +805,7 @@ pub fn to_str_radix(num: f32, rdx: uint) -> ~str { /// * num - The float value /// * radix - The base to use /// -#[inline(always)] +#[inline] pub fn to_str_radix_special(num: f32, rdx: uint) -> (~str, bool) { strconv::to_str_common(&num, rdx, true, strconv::SignNeg, strconv::DigAll) @@ -820,7 +820,7 @@ pub fn to_str_radix_special(num: f32, rdx: uint) -> (~str, bool) { /// * num - The float value /// * digits - The number of significant digits /// -#[inline(always)] +#[inline] pub fn to_str_exact(num: f32, dig: uint) -> ~str { let (r, _) = strconv::to_str_common( &num, 10u, true, strconv::SignNeg, strconv::DigExact(dig)); @@ -836,7 +836,7 @@ pub fn to_str_exact(num: f32, dig: uint) -> ~str { /// * num - The float value /// * digits - The number of significant digits /// -#[inline(always)] +#[inline] pub fn to_str_digits(num: f32, dig: uint) -> ~str { let (r, _) = strconv::to_str_common( &num, 10u, true, strconv::SignNeg, strconv::DigMax(dig)); @@ -844,12 +844,12 @@ pub fn to_str_digits(num: f32, dig: uint) -> ~str { } impl to_str::ToStr for f32 { - #[inline(always)] + #[inline] fn to_str(&self) -> ~str { to_str_digits(*self, 8) } } impl num::ToStrRadix for f32 { - #[inline(always)] + #[inline] fn to_str_radix(&self, rdx: uint) -> ~str { to_str_radix(*self, rdx) } @@ -882,7 +882,7 @@ impl num::ToStrRadix for f32 { /// `none` if the string did not represent a valid number. Otherwise, /// `Some(n)` where `n` is the floating-point number represented by `num`. /// -#[inline(always)] +#[inline] pub fn from_str(num: &str) -> Option { strconv::from_str_common(num, 10u, true, true, true, strconv::ExpDec, false, false) @@ -915,7 +915,7 @@ pub fn from_str(num: &str) -> Option { /// `none` if the string did not represent a valid number. Otherwise, /// `Some(n)` where `n` is the floating-point number represented by `[num]`. /// -#[inline(always)] +#[inline] pub fn from_str_hex(num: &str) -> Option { strconv::from_str_common(num, 16u, true, true, true, strconv::ExpBin, false, false) @@ -940,19 +940,19 @@ pub fn from_str_hex(num: &str) -> Option { /// `none` if the string did not represent a valid number. Otherwise, /// `Some(n)` where `n` is the floating-point number represented by `num`. /// -#[inline(always)] +#[inline] pub fn from_str_radix(num: &str, rdx: uint) -> Option { strconv::from_str_common(num, rdx, true, true, false, strconv::ExpNone, false, false) } impl FromStr for f32 { - #[inline(always)] + #[inline] fn from_str(val: &str) -> Option { from_str(val) } } impl num::FromStrRadix for f32 { - #[inline(always)] + #[inline] fn from_str_radix(val: &str, rdx: uint) -> Option { from_str_radix(val, rdx) } diff --git a/src/libstd/num/f64.rs b/src/libstd/num/f64.rs index de44d861645b3..c0c8bb88ce5cf 100644 --- a/src/libstd/num/f64.rs +++ b/src/libstd/num/f64.rs @@ -22,7 +22,7 @@ use to_str; pub use cmath::c_double_targ_consts::*; pub use cmp::{min, max}; -// An inner module is required to get the #[inline(always)] attribute on the +// An inner module is required to get the #[inline(force)] attribute on the // functions. pub use self::delegated::*; @@ -42,7 +42,7 @@ macro_rules! delegate( use unstable::intrinsics; $( - #[inline(always)] + #[inline(force)] pub fn $name($( $arg : $arg_ty ),*) -> $rv { unsafe { $bound_name($( $arg ),*) @@ -141,45 +141,45 @@ pub static infinity: f64 = 1.0_f64/0.0_f64; pub static neg_infinity: f64 = -1.0_f64/0.0_f64; -#[inline(always)] +#[inline(force)] pub fn add(x: f64, y: f64) -> f64 { return x + y; } -#[inline(always)] +#[inline(force)] pub fn sub(x: f64, y: f64) -> f64 { return x - y; } -#[inline(always)] +#[inline(force)] pub fn mul(x: f64, y: f64) -> f64 { return x * y; } -#[inline(always)] +#[inline(force)] pub fn div(x: f64, y: f64) -> f64 { return x / y; } -#[inline(always)] +#[inline(force)] pub fn rem(x: f64, y: f64) -> f64 { return x % y; } -#[inline(always)] +#[inline(force)] pub fn lt(x: f64, y: f64) -> bool { return x < y; } -#[inline(always)] +#[inline(force)] pub fn le(x: f64, y: f64) -> bool { return x <= y; } -#[inline(always)] +#[inline(force)] pub fn eq(x: f64, y: f64) -> bool { return x == y; } -#[inline(always)] +#[inline(force)] pub fn ne(x: f64, y: f64) -> bool { return x != y; } -#[inline(always)] +#[inline(force)] pub fn ge(x: f64, y: f64) -> bool { return x >= y; } -#[inline(always)] +#[inline(force)] pub fn gt(x: f64, y: f64) -> bool { return x > y; } -#[inline(always)] +#[inline(force)] pub fn fmax(x: f64, y: f64) -> f64 { if x >= y || y.is_NaN() { x } else { y } } -#[inline(always)] +#[inline(force)] pub fn fmin(x: f64, y: f64) -> f64 { if x <= y || y.is_NaN() { x } else { y } } @@ -234,23 +234,23 @@ impl Num for f64 {} #[cfg(not(test))] impl Eq for f64 { - #[inline(always)] + #[inline(force)] fn eq(&self, other: &f64) -> bool { (*self) == (*other) } - #[inline(always)] + #[inline(force)] fn ne(&self, other: &f64) -> bool { (*self) != (*other) } } #[cfg(not(test))] impl ApproxEq for f64 { - #[inline(always)] + #[inline(force)] fn approx_epsilon() -> f64 { 1.0e-6 } - #[inline(always)] + #[inline(force)] fn approx_eq(&self, other: &f64) -> bool { self.approx_eq_eps(other, &ApproxEq::approx_epsilon::()) } - #[inline(always)] + #[inline(force)] fn approx_eq_eps(&self, other: &f64, approx_epsilon: &f64) -> bool { (*self - *other).abs() < *approx_epsilon } @@ -258,32 +258,32 @@ impl ApproxEq for f64 { #[cfg(not(test))] impl Ord for f64 { - #[inline(always)] + #[inline(force)] fn lt(&self, other: &f64) -> bool { (*self) < (*other) } - #[inline(always)] + #[inline(force)] fn le(&self, other: &f64) -> bool { (*self) <= (*other) } - #[inline(always)] + #[inline(force)] fn ge(&self, other: &f64) -> bool { (*self) >= (*other) } - #[inline(always)] + #[inline(force)] fn gt(&self, other: &f64) -> bool { (*self) > (*other) } } impl Orderable for f64 { /// Returns `NaN` if either of the numbers are `NaN`. - #[inline(always)] + #[inline(force)] fn min(&self, other: &f64) -> f64 { if self.is_NaN() || other.is_NaN() { Float::NaN() } else { fmin(*self, *other) } } /// Returns `NaN` if either of the numbers are `NaN`. - #[inline(always)] + #[inline(force)] fn max(&self, other: &f64) -> f64 { if self.is_NaN() || other.is_NaN() { Float::NaN() } else { fmax(*self, *other) } } /// Returns the number constrained within the range `mn <= self <= mx`. /// If any of the numbers are `NaN` then `NaN` is returned. - #[inline(always)] + #[inline(force)] fn clamp(&self, mn: &f64, mx: &f64) -> f64 { cond!( (self.is_NaN()) { *self } @@ -295,16 +295,16 @@ impl Orderable for f64 { } impl Zero for f64 { - #[inline(always)] + #[inline(force)] fn zero() -> f64 { 0.0 } /// Returns true if the number is equal to either `0.0` or `-0.0` - #[inline(always)] + #[inline(force)] fn is_zero(&self) -> bool { *self == 0.0 || *self == -0.0 } } impl One for f64 { - #[inline(always)] + #[inline(force)] fn one() -> f64 { 1.0 } } @@ -326,7 +326,7 @@ impl Div for f64 { } #[cfg(not(test))] impl Rem for f64 { - #[inline(always)] + #[inline(force)] fn rem(&self, other: &f64) -> f64 { *self % *other } } #[cfg(not(test))] @@ -336,14 +336,14 @@ impl Neg for f64 { impl Signed for f64 { /// Computes the absolute value. Returns `NaN` if the number is `NaN`. - #[inline(always)] + #[inline(force)] fn abs(&self) -> f64 { abs(*self) } /// /// The positive difference of two numbers. Returns `0.0` if the number is less than or /// equal to `other`, otherwise the difference between`self` and `other` is returned. /// - #[inline(always)] + #[inline(force)] fn abs_sub(&self, other: &f64) -> f64 { abs_sub(*self, *other) } /// @@ -353,35 +353,35 @@ impl Signed for f64 { /// - `-1.0` if the number is negative, `-0.0` or `neg_infinity` /// - `NaN` if the number is NaN /// - #[inline(always)] + #[inline(force)] fn signum(&self) -> f64 { if self.is_NaN() { NaN } else { copysign(1.0, *self) } } /// Returns `true` if the number is positive, including `+0.0` and `infinity` - #[inline(always)] + #[inline(force)] fn is_positive(&self) -> bool { *self > 0.0 || (1.0 / *self) == infinity } /// Returns `true` if the number is negative, including `-0.0` and `neg_infinity` - #[inline(always)] + #[inline(force)] fn is_negative(&self) -> bool { *self < 0.0 || (1.0 / *self) == neg_infinity } } impl Round for f64 { /// Round half-way cases toward `neg_infinity` - #[inline(always)] + #[inline(force)] fn floor(&self) -> f64 { floor(*self) } /// Round half-way cases toward `infinity` - #[inline(always)] + #[inline(force)] fn ceil(&self) -> f64 { ceil(*self) } /// Round half-way cases away from `0.0` - #[inline(always)] + #[inline(force)] fn round(&self) -> f64 { round(*self) } /// The integer part of the number (rounds towards `0.0`) - #[inline(always)] + #[inline(force)] fn trunc(&self) -> f64 { trunc(*self) } /// @@ -391,57 +391,57 @@ impl Round for f64 { /// assert!(x == trunc(x) + fract(x)) /// ~~~ /// - #[inline(always)] + #[inline(force)] fn fract(&self) -> f64 { *self - self.trunc() } } impl Fractional for f64 { /// The reciprocal (multiplicative inverse) of the number - #[inline(always)] + #[inline(force)] fn recip(&self) -> f64 { 1.0 / *self } } impl Algebraic for f64 { - #[inline(always)] + #[inline(force)] fn pow(&self, n: f64) -> f64 { pow(*self, n) } - #[inline(always)] + #[inline(force)] fn sqrt(&self) -> f64 { sqrt(*self) } - #[inline(always)] + #[inline(force)] fn rsqrt(&self) -> f64 { self.sqrt().recip() } - #[inline(always)] + #[inline(force)] fn cbrt(&self) -> f64 { cbrt(*self) } - #[inline(always)] + #[inline(force)] fn hypot(&self, other: f64) -> f64 { hypot(*self, other) } } impl Trigonometric for f64 { - #[inline(always)] + #[inline(force)] fn sin(&self) -> f64 { sin(*self) } - #[inline(always)] + #[inline(force)] fn cos(&self) -> f64 { cos(*self) } - #[inline(always)] + #[inline(force)] fn tan(&self) -> f64 { tan(*self) } - #[inline(always)] + #[inline(force)] fn asin(&self) -> f64 { asin(*self) } - #[inline(always)] + #[inline(force)] fn acos(&self) -> f64 { acos(*self) } - #[inline(always)] + #[inline(force)] fn atan(&self) -> f64 { atan(*self) } - #[inline(always)] + #[inline(force)] fn atan2(&self, other: f64) -> f64 { atan2(*self, other) } /// Simultaneously computes the sine and cosine of the number - #[inline(always)] + #[inline(force)] fn sin_cos(&self) -> (f64, f64) { (self.sin(), self.cos()) } @@ -449,38 +449,38 @@ impl Trigonometric for f64 { impl Exponential for f64 { /// Returns the exponential of the number - #[inline(always)] + #[inline(force)] fn exp(&self) -> f64 { exp(*self) } /// Returns 2 raised to the power of the number - #[inline(always)] + #[inline(force)] fn exp2(&self) -> f64 { exp2(*self) } /// Returns the natural logarithm of the number - #[inline(always)] + #[inline(force)] fn ln(&self) -> f64 { ln(*self) } /// Returns the logarithm of the number with respect to an arbitrary base - #[inline(always)] + #[inline(force)] fn log(&self, base: f64) -> f64 { self.ln() / base.ln() } /// Returns the base 2 logarithm of the number - #[inline(always)] + #[inline(force)] fn log2(&self) -> f64 { log2(*self) } /// Returns the base 10 logarithm of the number - #[inline(always)] + #[inline(force)] fn log10(&self) -> f64 { log10(*self) } } impl Hyperbolic for f64 { - #[inline(always)] + #[inline(force)] fn sinh(&self) -> f64 { sinh(*self) } - #[inline(always)] + #[inline(force)] fn cosh(&self) -> f64 { cosh(*self) } - #[inline(always)] + #[inline(force)] fn tanh(&self) -> f64 { tanh(*self) } /// @@ -492,7 +492,7 @@ impl Hyperbolic for f64 { /// - `self` if `self` is `0.0`, `-0.0`, `infinity`, or `neg_infinity` /// - `NaN` if `self` is `NaN` /// - #[inline(always)] + #[inline(force)] fn asinh(&self) -> f64 { match *self { neg_infinity => neg_infinity, @@ -509,7 +509,7 @@ impl Hyperbolic for f64 { /// - `infinity` if `self` is `infinity` /// - `NaN` if `self` is `NaN` or `self < 1.0` (including `neg_infinity`) /// - #[inline(always)] + #[inline(force)] fn acosh(&self) -> f64 { match *self { x if x < 1.0 => Float::NaN(), @@ -529,7 +529,7 @@ impl Hyperbolic for f64 { /// - `NaN` if the `self` is `NaN` or outside the domain of `-1.0 <= self <= 1.0` /// (including `infinity` and `neg_infinity`) /// - #[inline(always)] + #[inline(force)] fn atanh(&self) -> f64 { 0.5 * ((2.0 * *self) / (1.0 - *self)).ln_1p() } @@ -537,159 +537,159 @@ impl Hyperbolic for f64 { impl Real for f64 { /// Archimedes' constant - #[inline(always)] + #[inline(force)] fn pi() -> f64 { 3.14159265358979323846264338327950288 } /// 2.0 * pi - #[inline(always)] + #[inline(force)] fn two_pi() -> f64 { 6.28318530717958647692528676655900576 } /// pi / 2.0 - #[inline(always)] + #[inline(force)] fn frac_pi_2() -> f64 { 1.57079632679489661923132169163975144 } /// pi / 3.0 - #[inline(always)] + #[inline(force)] fn frac_pi_3() -> f64 { 1.04719755119659774615421446109316763 } /// pi / 4.0 - #[inline(always)] + #[inline(force)] fn frac_pi_4() -> f64 { 0.785398163397448309615660845819875721 } /// pi / 6.0 - #[inline(always)] + #[inline(force)] fn frac_pi_6() -> f64 { 0.52359877559829887307710723054658381 } /// pi / 8.0 - #[inline(always)] + #[inline(force)] fn frac_pi_8() -> f64 { 0.39269908169872415480783042290993786 } /// 1.0 / pi - #[inline(always)] + #[inline(force)] fn frac_1_pi() -> f64 { 0.318309886183790671537767526745028724 } /// 2.0 / pi - #[inline(always)] + #[inline(force)] fn frac_2_pi() -> f64 { 0.636619772367581343075535053490057448 } /// 2.0 / sqrt(pi) - #[inline(always)] + #[inline(force)] fn frac_2_sqrtpi() -> f64 { 1.12837916709551257389615890312154517 } /// sqrt(2.0) - #[inline(always)] + #[inline(force)] fn sqrt2() -> f64 { 1.41421356237309504880168872420969808 } /// 1.0 / sqrt(2.0) - #[inline(always)] + #[inline(force)] fn frac_1_sqrt2() -> f64 { 0.707106781186547524400844362104849039 } /// Euler's number - #[inline(always)] + #[inline(force)] fn e() -> f64 { 2.71828182845904523536028747135266250 } /// log2(e) - #[inline(always)] + #[inline(force)] fn log2_e() -> f64 { 1.44269504088896340735992468100189214 } /// log10(e) - #[inline(always)] + #[inline(force)] fn log10_e() -> f64 { 0.434294481903251827651128918916605082 } /// ln(2.0) - #[inline(always)] + #[inline(force)] fn ln_2() -> f64 { 0.693147180559945309417232121458176568 } /// ln(10.0) - #[inline(always)] + #[inline(force)] fn ln_10() -> f64 { 2.30258509299404568401799145468436421 } /// Converts to degrees, assuming the number is in radians - #[inline(always)] + #[inline(force)] fn to_degrees(&self) -> f64 { *self * (180.0 / Real::pi::()) } /// Converts to radians, assuming the number is in degrees - #[inline(always)] + #[inline(force)] fn to_radians(&self) -> f64 { *self * (Real::pi::() / 180.0) } } impl RealExt for f64 { - #[inline(always)] + #[inline(force)] fn lgamma(&self) -> (int, f64) { let mut sign = 0; let result = lgamma(*self, &mut sign); (sign as int, result) } - #[inline(always)] + #[inline(force)] fn tgamma(&self) -> f64 { tgamma(*self) } - #[inline(always)] + #[inline(force)] fn j0(&self) -> f64 { j0(*self) } - #[inline(always)] + #[inline(force)] fn j1(&self) -> f64 { j1(*self) } - #[inline(always)] + #[inline(force)] fn jn(&self, n: int) -> f64 { jn(n as c_int, *self) } - #[inline(always)] + #[inline(force)] fn y0(&self) -> f64 { y0(*self) } - #[inline(always)] + #[inline(force)] fn y1(&self) -> f64 { y1(*self) } - #[inline(always)] + #[inline(force)] fn yn(&self, n: int) -> f64 { yn(n as c_int, *self) } } impl Bounded for f64 { - #[inline(always)] + #[inline(force)] fn min_value() -> f64 { 2.2250738585072014e-308 } - #[inline(always)] + #[inline(force)] fn max_value() -> f64 { 1.7976931348623157e+308 } } impl Primitive for f64 { - #[inline(always)] + #[inline(force)] fn bits() -> uint { 64 } - #[inline(always)] + #[inline(force)] fn bytes() -> uint { Primitive::bits::() / 8 } } impl Float for f64 { - #[inline(always)] + #[inline(force)] fn NaN() -> f64 { 0.0 / 0.0 } - #[inline(always)] + #[inline(force)] fn infinity() -> f64 { 1.0 / 0.0 } - #[inline(always)] + #[inline(force)] fn neg_infinity() -> f64 { -1.0 / 0.0 } - #[inline(always)] + #[inline(force)] fn neg_zero() -> f64 { -0.0 } /// Returns `true` if the number is NaN - #[inline(always)] + #[inline(force)] fn is_NaN(&self) -> bool { *self != *self } /// Returns `true` if the number is infinite - #[inline(always)] + #[inline(force)] fn is_infinite(&self) -> bool { *self == Float::infinity() || *self == Float::neg_infinity() } /// Returns `true` if the number is neither infinite or NaN - #[inline(always)] + #[inline(force)] fn is_finite(&self) -> bool { !(self.is_NaN() || self.is_infinite()) } /// Returns `true` if the number is neither zero, infinite, subnormal or NaN - #[inline(always)] + #[inline(force)] fn is_normal(&self) -> bool { self.classify() == FPNormal } @@ -712,29 +712,29 @@ impl Float for f64 { } } - #[inline(always)] + #[inline(force)] fn mantissa_digits() -> uint { 53 } - #[inline(always)] + #[inline(force)] fn digits() -> uint { 15 } - #[inline(always)] + #[inline(force)] fn epsilon() -> f64 { 2.2204460492503131e-16 } - #[inline(always)] + #[inline(force)] fn min_exp() -> int { -1021 } - #[inline(always)] + #[inline(force)] fn max_exp() -> int { 1024 } - #[inline(always)] + #[inline(force)] fn min_10_exp() -> int { -307 } - #[inline(always)] + #[inline(force)] fn max_10_exp() -> int { 308 } /// Constructs a floating point number by multiplying `x` by 2 raised to the power of `exp` - #[inline(always)] + #[inline(force)] fn ldexp(x: f64, exp: int) -> f64 { ldexp(x, exp as c_int) } @@ -745,7 +745,7 @@ impl Float for f64 { /// - `self = x * pow(2, exp)` /// - `0.5 <= abs(x) < 1.0` /// - #[inline(always)] + #[inline(force)] fn frexp(&self) -> (f64, int) { let mut exp = 0; let x = frexp(*self, &mut exp); @@ -756,14 +756,14 @@ impl Float for f64 { /// Returns the exponential of the number, minus `1`, in a way that is accurate /// even if the number is close to zero /// - #[inline(always)] + #[inline(force)] fn exp_m1(&self) -> f64 { exp_m1(*self) } /// /// Returns the natural logarithm of the number plus `1` (`ln(1+n)`) more accurately /// than if the operations were performed separately /// - #[inline(always)] + #[inline(force)] fn ln_1p(&self) -> f64 { ln_1p(*self) } /// @@ -771,13 +771,13 @@ impl Float for f64 { /// produces a more accurate result with better performance than a separate multiplication /// operation followed by an add. /// - #[inline(always)] + #[inline(force)] fn mul_add(&self, a: f64, b: f64) -> f64 { mul_add(*self, a, b) } /// Returns the next representable floating-point value in the direction of `other` - #[inline(always)] + #[inline(force)] fn next_after(&self, other: f64) -> f64 { next_after(*self, other) } @@ -794,7 +794,7 @@ impl Float for f64 { /// /// * num - The float value /// -#[inline(always)] +#[inline] pub fn to_str(num: f64) -> ~str { let (r, _) = strconv::to_str_common( &num, 10u, true, strconv::SignNeg, strconv::DigAll); @@ -808,7 +808,7 @@ pub fn to_str(num: f64) -> ~str { /// /// * num - The float value /// -#[inline(always)] +#[inline] pub fn to_str_hex(num: f64) -> ~str { let (r, _) = strconv::to_str_common( &num, 16u, true, strconv::SignNeg, strconv::DigAll); @@ -829,7 +829,7 @@ pub fn to_str_hex(num: f64) -> ~str { /// possible misinterpretation of the result at higher bases. If those values /// are expected, use `to_str_radix_special()` instead. /// -#[inline(always)] +#[inline] pub fn to_str_radix(num: f64, rdx: uint) -> ~str { let (r, special) = strconv::to_str_common( &num, rdx, true, strconv::SignNeg, strconv::DigAll); @@ -847,7 +847,7 @@ pub fn to_str_radix(num: f64, rdx: uint) -> ~str { /// * num - The float value /// * radix - The base to use /// -#[inline(always)] +#[inline] pub fn to_str_radix_special(num: f64, rdx: uint) -> (~str, bool) { strconv::to_str_common(&num, rdx, true, strconv::SignNeg, strconv::DigAll) @@ -862,7 +862,7 @@ pub fn to_str_radix_special(num: f64, rdx: uint) -> (~str, bool) { /// * num - The float value /// * digits - The number of significant digits /// -#[inline(always)] +#[inline] pub fn to_str_exact(num: f64, dig: uint) -> ~str { let (r, _) = strconv::to_str_common( &num, 10u, true, strconv::SignNeg, strconv::DigExact(dig)); @@ -878,7 +878,7 @@ pub fn to_str_exact(num: f64, dig: uint) -> ~str { /// * num - The float value /// * digits - The number of significant digits /// -#[inline(always)] +#[inline] pub fn to_str_digits(num: f64, dig: uint) -> ~str { let (r, _) = strconv::to_str_common( &num, 10u, true, strconv::SignNeg, strconv::DigMax(dig)); @@ -886,12 +886,12 @@ pub fn to_str_digits(num: f64, dig: uint) -> ~str { } impl to_str::ToStr for f64 { - #[inline(always)] + #[inline] fn to_str(&self) -> ~str { to_str_digits(*self, 8) } } impl num::ToStrRadix for f64 { - #[inline(always)] + #[inline] fn to_str_radix(&self, rdx: uint) -> ~str { to_str_radix(*self, rdx) } @@ -924,7 +924,7 @@ impl num::ToStrRadix for f64 { /// `none` if the string did not represent a valid number. Otherwise, /// `Some(n)` where `n` is the floating-point number represented by `num`. /// -#[inline(always)] +#[inline] pub fn from_str(num: &str) -> Option { strconv::from_str_common(num, 10u, true, true, true, strconv::ExpDec, false, false) @@ -957,7 +957,7 @@ pub fn from_str(num: &str) -> Option { /// `none` if the string did not represent a valid number. Otherwise, /// `Some(n)` where `n` is the floating-point number represented by `[num]`. /// -#[inline(always)] +#[inline] pub fn from_str_hex(num: &str) -> Option { strconv::from_str_common(num, 16u, true, true, true, strconv::ExpBin, false, false) @@ -982,19 +982,19 @@ pub fn from_str_hex(num: &str) -> Option { /// `none` if the string did not represent a valid number. Otherwise, /// `Some(n)` where `n` is the floating-point number represented by `num`. /// -#[inline(always)] +#[inline] pub fn from_str_radix(num: &str, rdx: uint) -> Option { strconv::from_str_common(num, rdx, true, true, false, strconv::ExpNone, false, false) } impl FromStr for f64 { - #[inline(always)] + #[inline] fn from_str(val: &str) -> Option { from_str(val) } } impl num::FromStrRadix for f64 { - #[inline(always)] + #[inline] fn from_str_radix(val: &str, rdx: uint) -> Option { from_str_radix(val, rdx) } diff --git a/src/libstd/num/float.rs b/src/libstd/num/float.rs index 97d661d8fe2e7..0117e1fb2f8df 100644 --- a/src/libstd/num/float.rs +++ b/src/libstd/num/float.rs @@ -99,7 +99,7 @@ pub mod consts { /// /// * num - The float value /// -#[inline(always)] +#[inline] pub fn to_str(num: float) -> ~str { let (r, _) = strconv::to_str_common( &num, 10u, true, strconv::SignNeg, strconv::DigAll); @@ -113,7 +113,7 @@ pub fn to_str(num: float) -> ~str { /// /// * num - The float value /// -#[inline(always)] +#[inline] pub fn to_str_hex(num: float) -> ~str { let (r, _) = strconv::to_str_common( &num, 16u, true, strconv::SignNeg, strconv::DigAll); @@ -134,7 +134,7 @@ pub fn to_str_hex(num: float) -> ~str { /// possible misinterpretation of the result at higher bases. If those values /// are expected, use `to_str_radix_special()` instead. /// -#[inline(always)] +#[inline] pub fn to_str_radix(num: float, radix: uint) -> ~str { let (r, special) = strconv::to_str_common( &num, radix, true, strconv::SignNeg, strconv::DigAll); @@ -152,7 +152,7 @@ pub fn to_str_radix(num: float, radix: uint) -> ~str { /// * num - The float value /// * radix - The base to use /// -#[inline(always)] +#[inline] pub fn to_str_radix_special(num: float, radix: uint) -> (~str, bool) { strconv::to_str_common(&num, radix, true, strconv::SignNeg, strconv::DigAll) @@ -167,7 +167,7 @@ pub fn to_str_radix_special(num: float, radix: uint) -> (~str, bool) { /// * num - The float value /// * digits - The number of significant digits /// -#[inline(always)] +#[inline] pub fn to_str_exact(num: float, digits: uint) -> ~str { let (r, _) = strconv::to_str_common( &num, 10u, true, strconv::SignNeg, strconv::DigExact(digits)); @@ -183,7 +183,7 @@ pub fn to_str_exact(num: float, digits: uint) -> ~str { /// * num - The float value /// * digits - The number of significant digits /// -#[inline(always)] +#[inline] pub fn to_str_digits(num: float, digits: uint) -> ~str { let (r, _) = strconv::to_str_common( &num, 10u, true, strconv::SignNeg, strconv::DigMax(digits)); @@ -191,12 +191,12 @@ pub fn to_str_digits(num: float, digits: uint) -> ~str { } impl to_str::ToStr for float { - #[inline(always)] + #[inline] fn to_str(&self) -> ~str { to_str_digits(*self, 8) } } impl num::ToStrRadix for float { - #[inline(always)] + #[inline] fn to_str_radix(&self, radix: uint) -> ~str { to_str_radix(*self, radix) } @@ -229,7 +229,7 @@ impl num::ToStrRadix for float { /// `none` if the string did not represent a valid number. Otherwise, /// `Some(n)` where `n` is the floating-point number represented by `num`. /// -#[inline(always)] +#[inline] pub fn from_str(num: &str) -> Option { strconv::from_str_common(num, 10u, true, true, true, strconv::ExpDec, false, false) @@ -262,7 +262,7 @@ pub fn from_str(num: &str) -> Option { /// `none` if the string did not represent a valid number. Otherwise, /// `Some(n)` where `n` is the floating-point number represented by `[num]`. /// -#[inline(always)] +#[inline] pub fn from_str_hex(num: &str) -> Option { strconv::from_str_common(num, 16u, true, true, true, strconv::ExpBin, false, false) @@ -287,19 +287,19 @@ pub fn from_str_hex(num: &str) -> Option { /// `none` if the string did not represent a valid number. Otherwise, /// `Some(n)` where `n` is the floating-point number represented by `num`. /// -#[inline(always)] +#[inline] pub fn from_str_radix(num: &str, radix: uint) -> Option { strconv::from_str_common(num, radix, true, true, false, strconv::ExpNone, false, false) } impl FromStr for float { - #[inline(always)] + #[inline] fn from_str(val: &str) -> Option { from_str(val) } } impl num::FromStrRadix for float { - #[inline(always)] + #[inline] fn from_str_radix(val: &str, radix: uint) -> Option { from_str_radix(val, radix) } @@ -341,27 +341,27 @@ pub fn pow_with_uint(base: uint, pow: uint) -> float { return total; } -#[inline(always)] +#[inline(force)] pub fn abs(x: float) -> float { f64::abs(x as f64) as float } -#[inline(always)] +#[inline(force)] pub fn sqrt(x: float) -> float { f64::sqrt(x as f64) as float } -#[inline(always)] +#[inline(force)] pub fn atan(x: float) -> float { f64::atan(x as f64) as float } -#[inline(always)] +#[inline(force)] pub fn sin(x: float) -> float { f64::sin(x as f64) as float } -#[inline(always)] +#[inline(force)] pub fn cos(x: float) -> float { f64::cos(x as f64) as float } -#[inline(always)] +#[inline(force)] pub fn tan(x: float) -> float { f64::tan(x as f64) as float } @@ -370,23 +370,23 @@ impl Num for float {} #[cfg(not(test))] impl Eq for float { - #[inline(always)] + #[inline(force)] fn eq(&self, other: &float) -> bool { (*self) == (*other) } - #[inline(always)] + #[inline(force)] fn ne(&self, other: &float) -> bool { (*self) != (*other) } } #[cfg(not(test))] impl ApproxEq for float { - #[inline(always)] + #[inline(force)] fn approx_epsilon() -> float { 1.0e-6 } - #[inline(always)] + #[inline(force)] fn approx_eq(&self, other: &float) -> bool { self.approx_eq_eps(other, &ApproxEq::approx_epsilon::()) } - #[inline(always)] + #[inline(force)] fn approx_eq_eps(&self, other: &float, approx_epsilon: &float) -> bool { (*self - *other).abs() < *approx_epsilon } @@ -394,66 +394,66 @@ impl ApproxEq for float { #[cfg(not(test))] impl Ord for float { - #[inline(always)] + #[inline(force)] fn lt(&self, other: &float) -> bool { (*self) < (*other) } - #[inline(always)] + #[inline(force)] fn le(&self, other: &float) -> bool { (*self) <= (*other) } - #[inline(always)] + #[inline(force)] fn ge(&self, other: &float) -> bool { (*self) >= (*other) } - #[inline(always)] + #[inline(force)] fn gt(&self, other: &float) -> bool { (*self) > (*other) } } impl Orderable for float { /// Returns `NaN` if either of the numbers are `NaN`. - #[inline(always)] + #[inline(force)] fn min(&self, other: &float) -> float { (*self as f64).min(&(*other as f64)) as float } /// Returns `NaN` if either of the numbers are `NaN`. - #[inline(always)] + #[inline(force)] fn max(&self, other: &float) -> float { (*self as f64).max(&(*other as f64)) as float } /// Returns the number constrained within the range `mn <= self <= mx`. /// If any of the numbers are `NaN` then `NaN` is returned. - #[inline(always)] + #[inline(force)] fn clamp(&self, mn: &float, mx: &float) -> float { (*self as f64).clamp(&(*mn as f64), &(*mx as f64)) as float } } impl Zero for float { - #[inline(always)] + #[inline(force)] fn zero() -> float { 0.0 } /// Returns true if the number is equal to either `0.0` or `-0.0` - #[inline(always)] + #[inline(force)] fn is_zero(&self) -> bool { *self == 0.0 || *self == -0.0 } } impl One for float { - #[inline(always)] + #[inline(force)] fn one() -> float { 1.0 } } impl Round for float { /// Round half-way cases toward `neg_infinity` - #[inline(always)] + #[inline(force)] fn floor(&self) -> float { floor(*self as f64) as float } /// Round half-way cases toward `infinity` - #[inline(always)] + #[inline(force)] fn ceil(&self) -> float { ceil(*self as f64) as float } /// Round half-way cases away from `0.0` - #[inline(always)] + #[inline(force)] fn round(&self) -> float { round(*self as f64) as float } /// The integer part of the number (rounds towards `0.0`) - #[inline(always)] + #[inline(force)] fn trunc(&self) -> float { trunc(*self as f64) as float } /// @@ -463,81 +463,81 @@ impl Round for float { /// assert!(x == trunc(x) + fract(x)) /// ~~~ /// - #[inline(always)] + #[inline(force)] fn fract(&self) -> float { *self - self.trunc() } } impl Fractional for float { /// The reciprocal (multiplicative inverse) of the number - #[inline(always)] + #[inline(force)] fn recip(&self) -> float { 1.0 / *self } } impl Algebraic for float { - #[inline(always)] + #[inline(force)] fn pow(&self, n: float) -> float { (*self as f64).pow(n as f64) as float } - #[inline(always)] + #[inline(force)] fn sqrt(&self) -> float { (*self as f64).sqrt() as float } - #[inline(always)] + #[inline(force)] fn rsqrt(&self) -> float { (*self as f64).rsqrt() as float } - #[inline(always)] + #[inline(force)] fn cbrt(&self) -> float { (*self as f64).cbrt() as float } - #[inline(always)] + #[inline(force)] fn hypot(&self, other: float) -> float { (*self as f64).hypot(other as f64) as float } } impl Trigonometric for float { - #[inline(always)] + #[inline(force)] fn sin(&self) -> float { (*self as f64).sin() as float } - #[inline(always)] + #[inline(force)] fn cos(&self) -> float { (*self as f64).cos() as float } - #[inline(always)] + #[inline(force)] fn tan(&self) -> float { (*self as f64).tan() as float } - #[inline(always)] + #[inline(force)] fn asin(&self) -> float { (*self as f64).asin() as float } - #[inline(always)] + #[inline(force)] fn acos(&self) -> float { (*self as f64).acos() as float } - #[inline(always)] + #[inline(force)] fn atan(&self) -> float { (*self as f64).atan() as float } - #[inline(always)] + #[inline(force)] fn atan2(&self, other: float) -> float { (*self as f64).atan2(other as f64) as float } /// Simultaneously computes the sine and cosine of the number - #[inline(always)] + #[inline(force)] fn sin_cos(&self) -> (float, float) { match (*self as f64).sin_cos() { (s, c) => (s as float, c as float) @@ -547,54 +547,54 @@ impl Trigonometric for float { impl Exponential for float { /// Returns the exponential of the number - #[inline(always)] + #[inline(force)] fn exp(&self) -> float { (*self as f64).exp() as float } /// Returns 2 raised to the power of the number - #[inline(always)] + #[inline(force)] fn exp2(&self) -> float { (*self as f64).exp2() as float } /// Returns the natural logarithm of the number - #[inline(always)] + #[inline(force)] fn ln(&self) -> float { (*self as f64).ln() as float } /// Returns the logarithm of the number with respect to an arbitrary base - #[inline(always)] + #[inline(force)] fn log(&self, base: float) -> float { (*self as f64).log(base as f64) as float } /// Returns the base 2 logarithm of the number - #[inline(always)] + #[inline(force)] fn log2(&self) -> float { (*self as f64).log2() as float } /// Returns the base 10 logarithm of the number - #[inline(always)] + #[inline(force)] fn log10(&self) -> float { (*self as f64).log10() as float } } impl Hyperbolic for float { - #[inline(always)] + #[inline(force)] fn sinh(&self) -> float { (*self as f64).sinh() as float } - #[inline(always)] + #[inline(force)] fn cosh(&self) -> float { (*self as f64).cosh() as float } - #[inline(always)] + #[inline(force)] fn tanh(&self) -> float { (*self as f64).tanh() as float } @@ -608,7 +608,7 @@ impl Hyperbolic for float { /// - `self` if `self` is `0.0`, `-0.0`, `infinity`, or `neg_infinity` /// - `NaN` if `self` is `NaN` /// - #[inline(always)] + #[inline(force)] fn asinh(&self) -> float { (*self as f64).asinh() as float } @@ -622,7 +622,7 @@ impl Hyperbolic for float { /// - `infinity` if `self` is `infinity` /// - `NaN` if `self` is `NaN` or `self < 1.0` (including `neg_infinity`) /// - #[inline(always)] + #[inline(force)] fn acosh(&self) -> float { (*self as f64).acosh() as float } @@ -639,7 +639,7 @@ impl Hyperbolic for float { /// - `NaN` if the `self` is `NaN` or outside the domain of `-1.0 <= self <= 1.0` /// (including `infinity` and `neg_infinity`) /// - #[inline(always)] + #[inline(force)] fn atanh(&self) -> float { (*self as f64).atanh() as float } @@ -647,157 +647,157 @@ impl Hyperbolic for float { impl Real for float { /// Archimedes' constant - #[inline(always)] + #[inline(force)] fn pi() -> float { 3.14159265358979323846264338327950288 } /// 2.0 * pi - #[inline(always)] + #[inline(force)] fn two_pi() -> float { 6.28318530717958647692528676655900576 } /// pi / 2.0 - #[inline(always)] + #[inline(force)] fn frac_pi_2() -> float { 1.57079632679489661923132169163975144 } /// pi / 3.0 - #[inline(always)] + #[inline(force)] fn frac_pi_3() -> float { 1.04719755119659774615421446109316763 } /// pi / 4.0 - #[inline(always)] + #[inline(force)] fn frac_pi_4() -> float { 0.785398163397448309615660845819875721 } /// pi / 6.0 - #[inline(always)] + #[inline(force)] fn frac_pi_6() -> float { 0.52359877559829887307710723054658381 } /// pi / 8.0 - #[inline(always)] + #[inline(force)] fn frac_pi_8() -> float { 0.39269908169872415480783042290993786 } /// 1.0 / pi - #[inline(always)] + #[inline(force)] fn frac_1_pi() -> float { 0.318309886183790671537767526745028724 } /// 2.0 / pi - #[inline(always)] + #[inline(force)] fn frac_2_pi() -> float { 0.636619772367581343075535053490057448 } /// 2 .0/ sqrt(pi) - #[inline(always)] + #[inline(force)] fn frac_2_sqrtpi() -> float { 1.12837916709551257389615890312154517 } /// sqrt(2.0) - #[inline(always)] + #[inline(force)] fn sqrt2() -> float { 1.41421356237309504880168872420969808 } /// 1.0 / sqrt(2.0) - #[inline(always)] + #[inline(force)] fn frac_1_sqrt2() -> float { 0.707106781186547524400844362104849039 } /// Euler's number - #[inline(always)] + #[inline(force)] fn e() -> float { 2.71828182845904523536028747135266250 } /// log2(e) - #[inline(always)] + #[inline(force)] fn log2_e() -> float { 1.44269504088896340735992468100189214 } /// log10(e) - #[inline(always)] + #[inline(force)] fn log10_e() -> float { 0.434294481903251827651128918916605082 } /// ln(2.0) - #[inline(always)] + #[inline(force)] fn ln_2() -> float { 0.693147180559945309417232121458176568 } /// ln(10.0) - #[inline(always)] + #[inline(force)] fn ln_10() -> float { 2.30258509299404568401799145468436421 } /// Converts to degrees, assuming the number is in radians - #[inline(always)] + #[inline(force)] fn to_degrees(&self) -> float { (*self as f64).to_degrees() as float } /// Converts to radians, assuming the number is in degrees - #[inline(always)] + #[inline(force)] fn to_radians(&self) -> float { (*self as f64).to_radians() as float } } impl RealExt for float { - #[inline(always)] + #[inline(force)] fn lgamma(&self) -> (int, float) { let mut sign = 0; let result = lgamma(*self as f64, &mut sign); (sign as int, result as float) } - #[inline(always)] + #[inline(force)] fn tgamma(&self) -> float { tgamma(*self as f64) as float } - #[inline(always)] + #[inline(force)] fn j0(&self) -> float { j0(*self as f64) as float } - #[inline(always)] + #[inline(force)] fn j1(&self) -> float { j1(*self as f64) as float } - #[inline(always)] + #[inline(force)] fn jn(&self, n: int) -> float { jn(n as c_int, *self as f64) as float } - #[inline(always)] + #[inline(force)] fn y0(&self) -> float { y0(*self as f64) as float } - #[inline(always)] + #[inline(force)] fn y1(&self) -> float { y1(*self as f64) as float } - #[inline(always)] + #[inline(force)] fn yn(&self, n: int) -> float { yn(n as c_int, *self as f64) as float } } #[cfg(not(test))] impl Add for float { - #[inline(always)] + #[inline(force)] fn add(&self, other: &float) -> float { *self + *other } } #[cfg(not(test))] impl Sub for float { - #[inline(always)] + #[inline(force)] fn sub(&self, other: &float) -> float { *self - *other } } #[cfg(not(test))] impl Mul for float { - #[inline(always)] + #[inline(force)] fn mul(&self, other: &float) -> float { *self * *other } } #[cfg(not(test))] impl Div for float { - #[inline(always)] + #[inline(force)] fn div(&self, other: &float) -> float { *self / *other } } #[cfg(not(test))] impl Rem for float { - #[inline(always)] + #[inline(force)] fn rem(&self, other: &float) -> float { *self % *other } } #[cfg(not(test))] impl Neg for float { - #[inline(always)] + #[inline(force)] fn neg(&self) -> float { -*self } } impl Signed for float { /// Computes the absolute value. Returns `NaN` if the number is `NaN`. - #[inline(always)] + #[inline(force)] fn abs(&self) -> float { abs(*self) } /// /// The positive difference of two numbers. Returns `0.0` if the number is less than or /// equal to `other`, otherwise the difference between`self` and `other` is returned. /// - #[inline(always)] + #[inline(force)] fn abs_sub(&self, other: &float) -> float { (*self as f64).abs_sub(&(*other as f64)) as float } @@ -809,93 +809,93 @@ impl Signed for float { /// - `-1.0` if the number is negative, `-0.0` or `neg_infinity` /// - `NaN` if the number is NaN /// - #[inline(always)] + #[inline(force)] fn signum(&self) -> float { if self.is_NaN() { NaN } else { f64::copysign(1.0, *self as f64) as float } } /// Returns `true` if the number is positive, including `+0.0` and `infinity` - #[inline(always)] + #[inline(force)] fn is_positive(&self) -> bool { *self > 0.0 || (1.0 / *self) == infinity } /// Returns `true` if the number is negative, including `-0.0` and `neg_infinity` - #[inline(always)] + #[inline(force)] fn is_negative(&self) -> bool { *self < 0.0 || (1.0 / *self) == neg_infinity } } impl Bounded for float { - #[inline(always)] + #[inline(force)] fn min_value() -> float { Bounded::min_value::() as float } - #[inline(always)] + #[inline(force)] fn max_value() -> float { Bounded::max_value::() as float } } impl Primitive for float { - #[inline(always)] + #[inline(force)] fn bits() -> uint { Primitive::bits::() } - #[inline(always)] + #[inline(force)] fn bytes() -> uint { Primitive::bytes::() } } impl Float for float { - #[inline(always)] + #[inline(force)] fn NaN() -> float { Float::NaN::() as float } - #[inline(always)] + #[inline(force)] fn infinity() -> float { Float::infinity::() as float } - #[inline(always)] + #[inline(force)] fn neg_infinity() -> float { Float::neg_infinity::() as float } - #[inline(always)] + #[inline(force)] fn neg_zero() -> float { Float::neg_zero::() as float } /// Returns `true` if the number is NaN - #[inline(always)] + #[inline(force)] fn is_NaN(&self) -> bool { (*self as f64).is_NaN() } /// Returns `true` if the number is infinite - #[inline(always)] + #[inline(force)] fn is_infinite(&self) -> bool { (*self as f64).is_infinite() } /// Returns `true` if the number is neither infinite or NaN - #[inline(always)] + #[inline(force)] fn is_finite(&self) -> bool { (*self as f64).is_finite() } /// Returns `true` if the number is neither zero, infinite, subnormal or NaN - #[inline(always)] + #[inline(force)] fn is_normal(&self) -> bool { (*self as f64).is_normal() } /// Returns the floating point category of the number. If only one property is going to /// be tested, it is generally faster to use the specific predicate instead. - #[inline(always)] + #[inline(force)] fn classify(&self) -> FPCategory { (*self as f64).classify() } - #[inline(always)] + #[inline(force)] fn mantissa_digits() -> uint { Float::mantissa_digits::() } - #[inline(always)] + #[inline(force)] fn digits() -> uint { Float::digits::() } - #[inline(always)] + #[inline(force)] fn epsilon() -> float { Float::epsilon::() as float } - #[inline(always)] + #[inline(force)] fn min_exp() -> int { Float::min_exp::() } - #[inline(always)] + #[inline(force)] fn max_exp() -> int { Float::max_exp::() } - #[inline(always)] + #[inline(force)] fn min_10_exp() -> int { Float::min_10_exp::() } - #[inline(always)] + #[inline(force)] fn max_10_exp() -> int { Float::max_10_exp::() } /// Constructs a floating point number by multiplying `x` by 2 raised to the power of `exp` - #[inline(always)] + #[inline(force)] fn ldexp(x: float, exp: int) -> float { Float::ldexp(x as f64, exp) as float } @@ -906,7 +906,7 @@ impl Float for float { /// - `self = x * pow(2, exp)` /// - `0.5 <= abs(x) < 1.0` /// - #[inline(always)] + #[inline(force)] fn frexp(&self) -> (float, int) { match (*self as f64).frexp() { (x, exp) => (x as float, exp) @@ -917,7 +917,7 @@ impl Float for float { /// Returns the exponential of the number, minus `1`, in a way that is accurate /// even if the number is close to zero /// - #[inline(always)] + #[inline(force)] fn exp_m1(&self) -> float { (*self as f64).exp_m1() as float } @@ -926,7 +926,7 @@ impl Float for float { /// Returns the natural logarithm of the number plus `1` (`ln(1+n)`) more accurately /// than if the operations were performed separately /// - #[inline(always)] + #[inline(force)] fn ln_1p(&self) -> float { (*self as f64).ln_1p() as float } @@ -936,13 +936,13 @@ impl Float for float { /// produces a more accurate result with better performance than a separate multiplication /// operation followed by an add. /// - #[inline(always)] + #[inline(force)] fn mul_add(&self, a: float, b: float) -> float { mul_add(*self as f64, a as f64, b as f64) as float } /// Returns the next representable floating-point value in the direction of `other` - #[inline(always)] + #[inline(force)] fn next_after(&self, other: float) -> float { next_after(*self as f64, other as f64) as float } diff --git a/src/libstd/num/i16.rs b/src/libstd/num/i16.rs index 9977247b249b5..8e15ba29f693e 100644 --- a/src/libstd/num/i16.rs +++ b/src/libstd/num/i16.rs @@ -19,14 +19,14 @@ int_module!(i16, 16) impl BitCount for i16 { /// Counts the number of bits set. Wraps LLVM's `ctpop` intrinsic. - #[inline(always)] + #[inline(force)] fn population_count(&self) -> i16 { unsafe { intrinsics::ctpop16(*self) } } /// Counts the number of leading zeros. Wraps LLVM's `ctlz` intrinsic. - #[inline(always)] + #[inline(force)] fn leading_zeros(&self) -> i16 { unsafe { intrinsics::ctlz16(*self) } } /// Counts the number of trailing zeros. Wraps LLVM's `cttz` intrinsic. - #[inline(always)] + #[inline(force)] fn trailing_zeros(&self) -> i16 { unsafe { intrinsics::cttz16(*self) } } } diff --git a/src/libstd/num/i32.rs b/src/libstd/num/i32.rs index 0115f306e4e0e..cb318bfae2d0b 100644 --- a/src/libstd/num/i32.rs +++ b/src/libstd/num/i32.rs @@ -19,14 +19,14 @@ int_module!(i32, 32) impl BitCount for i32 { /// Counts the number of bits set. Wraps LLVM's `ctpop` intrinsic. - #[inline(always)] + #[inline(force)] fn population_count(&self) -> i32 { unsafe { intrinsics::ctpop32(*self) } } /// Counts the number of leading zeros. Wraps LLVM's `ctlz` intrinsic. - #[inline(always)] + #[inline(force)] fn leading_zeros(&self) -> i32 { unsafe { intrinsics::ctlz32(*self) } } /// Counts the number of trailing zeros. Wraps LLVM's `cttz` intrinsic. - #[inline(always)] + #[inline(force)] fn trailing_zeros(&self) -> i32 { unsafe { intrinsics::cttz32(*self) } } } diff --git a/src/libstd/num/i64.rs b/src/libstd/num/i64.rs index 4e280f01f2720..db81a5240f6ab 100644 --- a/src/libstd/num/i64.rs +++ b/src/libstd/num/i64.rs @@ -19,14 +19,14 @@ int_module!(i64, 64) impl BitCount for i64 { /// Counts the number of bits set. Wraps LLVM's `ctpop` intrinsic. - #[inline(always)] + #[inline(force)] fn population_count(&self) -> i64 { unsafe { intrinsics::ctpop64(*self) } } /// Counts the number of leading zeros. Wraps LLVM's `ctlz` intrinsic. - #[inline(always)] + #[inline(force)] fn leading_zeros(&self) -> i64 { unsafe { intrinsics::ctlz64(*self) } } /// Counts the number of trailing zeros. Wraps LLVM's `cttz` intrinsic. - #[inline(always)] + #[inline(force)] fn trailing_zeros(&self) -> i64 { unsafe { intrinsics::cttz64(*self) } } } diff --git a/src/libstd/num/i8.rs b/src/libstd/num/i8.rs index 939965b969185..d11fabe90a91f 100644 --- a/src/libstd/num/i8.rs +++ b/src/libstd/num/i8.rs @@ -19,14 +19,14 @@ int_module!(i8, 8) impl BitCount for i8 { /// Counts the number of bits set. Wraps LLVM's `ctpop` intrinsic. - #[inline(always)] + #[inline(force)] fn population_count(&self) -> i8 { unsafe { intrinsics::ctpop8(*self) } } /// Counts the number of leading zeros. Wraps LLVM's `ctlz` intrinsic. - #[inline(always)] + #[inline(force)] fn leading_zeros(&self) -> i8 { unsafe { intrinsics::ctlz8(*self) } } /// Counts the number of trailing zeros. Wraps LLVM's `cttz` intrinsic. - #[inline(always)] + #[inline(force)] fn trailing_zeros(&self) -> i8 { unsafe { intrinsics::cttz8(*self) } } } diff --git a/src/libstd/num/int.rs b/src/libstd/num/int.rs index 96ef7e9e3412c..3f9a04eddd8cb 100644 --- a/src/libstd/num/int.rs +++ b/src/libstd/num/int.rs @@ -22,30 +22,30 @@ int_module!(int, super::bits) #[cfg(target_word_size = "32")] impl BitCount for int { /// Counts the number of bits set. Wraps LLVM's `ctpop` intrinsic. - #[inline(always)] + #[inline(force)] fn population_count(&self) -> int { (*self as i32).population_count() as int } /// Counts the number of leading zeros. Wraps LLVM's `ctlz` intrinsic. - #[inline(always)] + #[inline(force)] fn leading_zeros(&self) -> int { (*self as i32).leading_zeros() as int } /// Counts the number of trailing zeros. Wraps LLVM's `cttz` intrinsic. - #[inline(always)] + #[inline(force)] fn trailing_zeros(&self) -> int { (*self as i32).trailing_zeros() as int } } #[cfg(target_word_size = "64")] impl BitCount for int { /// Counts the number of bits set. Wraps LLVM's `ctpop` intrinsic. - #[inline(always)] + #[inline(force)] fn population_count(&self) -> int { (*self as i64).population_count() as int } /// Counts the number of leading zeros. Wraps LLVM's `ctlz` intrinsic. - #[inline(always)] + #[inline(force)] fn leading_zeros(&self) -> int { (*self as i64).leading_zeros() as int } /// Counts the number of trailing zeros. Wraps LLVM's `cttz` intrinsic. - #[inline(always)] + #[inline(force)] fn trailing_zeros(&self) -> int { (*self as i64).trailing_zeros() as int } } diff --git a/src/libstd/num/int_macros.rs b/src/libstd/num/int_macros.rs index 3583e2f366ff3..c9b48da705fcb 100644 --- a/src/libstd/num/int_macros.rs +++ b/src/libstd/num/int_macros.rs @@ -27,17 +27,17 @@ pub static min_value: $T = (-1 as $T) << (bits - 1); pub static max_value: $T = min_value - 1 as $T; /// Calculates the sum of two numbers -#[inline(always)] +#[inline(force)] pub fn add(x: $T, y: $T) -> $T { x + y } /// Subtracts the second number from the first -#[inline(always)] +#[inline(force)] pub fn sub(x: $T, y: $T) -> $T { x - y } /// Multiplies two numbers together -#[inline(always)] +#[inline(force)] pub fn mul(x: $T, y: $T) -> $T { x * y } /// Divides the first argument by the second argument (using integer division) /// Divides the first argument by the second argument (using integer division) -#[inline(always)] +#[inline(force)] pub fn div(x: $T, y: $T) -> $T { x / y } /// @@ -60,26 +60,26 @@ pub fn div(x: $T, y: $T) -> $T { x / y } /// ~~~ /// /// -#[inline(always)] +#[inline(force)] pub fn rem(x: $T, y: $T) -> $T { x % y } /// Returns true iff `x < y` -#[inline(always)] +#[inline(force)] pub fn lt(x: $T, y: $T) -> bool { x < y } /// Returns true iff `x <= y` -#[inline(always)] +#[inline(force)] pub fn le(x: $T, y: $T) -> bool { x <= y } /// Returns true iff `x == y` -#[inline(always)] +#[inline(force)] pub fn eq(x: $T, y: $T) -> bool { x == y } /// Returns true iff `x != y` -#[inline(always)] +#[inline(force)] pub fn ne(x: $T, y: $T) -> bool { x != y } /// Returns true iff `x >= y` -#[inline(always)] +#[inline(force)] pub fn ge(x: $T, y: $T) -> bool { x >= y } /// Returns true iff `x > y` -#[inline(always)] +#[inline(force)] pub fn gt(x: $T, y: $T) -> bool { x > y } /// @@ -99,7 +99,7 @@ pub fn gt(x: $T, y: $T) -> bool { x > y } /// assert!(sum == 10); /// ~~~ /// -#[inline(always)] +#[inline(force)] pub fn range_step(start: $T, stop: $T, step: $T, it: &fn($T) -> bool) -> bool { let mut i = start; if step == 0 { @@ -122,62 +122,62 @@ pub fn range_step(start: $T, stop: $T, step: $T, it: &fn($T) -> bool) -> bool { return true; } -#[inline(always)] +#[inline(force)] /// Iterate over the range [`lo`..`hi`) pub fn range(lo: $T, hi: $T, it: &fn($T) -> bool) -> bool { range_step(lo, hi, 1 as $T, it) } -#[inline(always)] +#[inline(force)] /// Iterate over the range [`hi`..`lo`) pub fn range_rev(hi: $T, lo: $T, it: &fn($T) -> bool) -> bool { range_step(hi, lo, -1 as $T, it) } /// Computes the bitwise complement -#[inline(always)] +#[inline(force)] pub fn compl(i: $T) -> $T { -1 as $T ^ i } /// Computes the absolute value -#[inline(always)] +#[inline(force)] pub fn abs(i: $T) -> $T { i.abs() } impl Num for $T {} #[cfg(not(test))] impl Ord for $T { - #[inline(always)] + #[inline(force)] fn lt(&self, other: &$T) -> bool { return (*self) < (*other); } - #[inline(always)] + #[inline(force)] fn le(&self, other: &$T) -> bool { return (*self) <= (*other); } - #[inline(always)] + #[inline(force)] fn ge(&self, other: &$T) -> bool { return (*self) >= (*other); } - #[inline(always)] + #[inline(force)] fn gt(&self, other: &$T) -> bool { return (*self) > (*other); } } #[cfg(not(test))] impl Eq for $T { - #[inline(always)] + #[inline(force)] fn eq(&self, other: &$T) -> bool { return (*self) == (*other); } - #[inline(always)] + #[inline(force)] fn ne(&self, other: &$T) -> bool { return (*self) != (*other); } } impl Orderable for $T { - #[inline(always)] + #[inline(force)] fn min(&self, other: &$T) -> $T { if *self < *other { *self } else { *other } } - #[inline(always)] + #[inline(force)] fn max(&self, other: &$T) -> $T { if *self > *other { *self } else { *other } } - #[inline(always)] + #[inline(force)] fn clamp(&self, mn: &$T, mx: &$T) -> $T { if *self > *mx { *mx } else if *self < *mn { *mn } else { *self } @@ -185,33 +185,33 @@ impl Orderable for $T { } impl Zero for $T { - #[inline(always)] + #[inline(force)] fn zero() -> $T { 0 } - #[inline(always)] + #[inline(force)] fn is_zero(&self) -> bool { *self == 0 } } impl One for $T { - #[inline(always)] + #[inline(force)] fn one() -> $T { 1 } } #[cfg(not(test))] impl Add<$T,$T> for $T { - #[inline(always)] + #[inline(force)] fn add(&self, other: &$T) -> $T { *self + *other } } #[cfg(not(test))] impl Sub<$T,$T> for $T { - #[inline(always)] + #[inline(force)] fn sub(&self, other: &$T) -> $T { *self - *other } } #[cfg(not(test))] impl Mul<$T,$T> for $T { - #[inline(always)] + #[inline(force)] fn mul(&self, other: &$T) -> $T { *self * *other } } @@ -235,7 +235,7 @@ impl Div<$T,$T> for $T { /// assert!(-1 / -2 == 0); /// ~~~ /// - #[inline(always)] + #[inline(force)] fn div(&self, other: &$T) -> $T { *self / *other } } @@ -262,19 +262,19 @@ impl Rem<$T,$T> for $T { /// assert!(-1 % -2 == -1); /// ~~~ /// - #[inline(always)] + #[inline(force)] fn rem(&self, other: &$T) -> $T { *self % *other } } #[cfg(not(test))] impl Neg<$T> for $T { - #[inline(always)] + #[inline(force)] fn neg(&self) -> $T { -*self } } impl Signed for $T { /// Computes the absolute value - #[inline(always)] + #[inline(force)] fn abs(&self) -> $T { if self.is_negative() { -*self } else { *self } } @@ -283,7 +283,7 @@ impl Signed for $T { /// The positive difference of two numbers. Returns `0` if the number is less than or /// equal to `other`, otherwise the difference between`self` and `other` is returned. /// - #[inline(always)] + #[inline(force)] fn abs_sub(&self, other: &$T) -> $T { if *self <= *other { 0 } else { *self - *other } } @@ -295,7 +295,7 @@ impl Signed for $T { /// - `1` if the number is positive /// - `-1` if the number is negative /// - #[inline(always)] + #[inline(force)] fn signum(&self) -> $T { match *self { n if n > 0 => 1, @@ -305,11 +305,11 @@ impl Signed for $T { } /// Returns true if the number is positive - #[inline(always)] + #[inline(force)] fn is_positive(&self) -> bool { *self > 0 } /// Returns true if the number is negative - #[inline(always)] + #[inline(force)] fn is_negative(&self) -> bool { *self < 0 } } @@ -331,7 +331,7 @@ impl Integer for $T { /// assert!((-1).div_floor(-2) == 0); /// ~~~ /// - #[inline(always)] + #[inline(force)] fn div_floor(&self, other: &$T) -> $T { // Algorithm from [Daan Leijen. _Division and Modulus for Computer Scientists_, // December 2001](http://research.microsoft.com/pubs/151917/divmodnote-letter.pdf) @@ -363,7 +363,7 @@ impl Integer for $T { /// assert!((-1).mod_floor(-2) == -1); /// ~~~ /// - #[inline(always)] + #[inline(force)] fn mod_floor(&self, other: &$T) -> $T { // Algorithm from [Daan Leijen. _Division and Modulus for Computer Scientists_, // December 2001](http://research.microsoft.com/pubs/151917/divmodnote-letter.pdf) @@ -375,7 +375,7 @@ impl Integer for $T { } /// Calculates `div_floor` and `mod_floor` simultaneously - #[inline(always)] + #[inline(force)] fn div_mod_floor(&self, other: &$T) -> ($T,$T) { // Algorithm from [Daan Leijen. _Division and Modulus for Computer Scientists_, // December 2001](http://research.microsoft.com/pubs/151917/divmodnote-letter.pdf) @@ -387,7 +387,7 @@ impl Integer for $T { } /// Calculates `div` (`\`) and `rem` (`%`) simultaneously - #[inline(always)] + #[inline(force)] fn div_rem(&self, other: &$T) -> ($T,$T) { (*self / *other, *self % *other) } @@ -397,7 +397,7 @@ impl Integer for $T { /// /// The result is always positive /// - #[inline(always)] + #[inline(force)] fn gcd(&self, other: &$T) -> $T { // Use Euclid's algorithm let mut (m, n) = (*self, *other); @@ -412,21 +412,21 @@ impl Integer for $T { /// /// Calculates the Lowest Common Multiple (LCM) of the number and `other` /// - #[inline(always)] + #[inline(force)] fn lcm(&self, other: &$T) -> $T { ((*self * *other) / self.gcd(other)).abs() // should not have to recaluculate abs } /// Returns `true` if the number can be divided by `other` without leaving a remainder - #[inline(always)] + #[inline(force)] fn is_multiple_of(&self, other: &$T) -> bool { *self % *other == 0 } /// Returns `true` if the number is divisible by `2` - #[inline(always)] + #[inline(force)] fn is_even(&self) -> bool { self.is_multiple_of(&2) } /// Returns `true` if the number is not divisible by `2` - #[inline(always)] + #[inline(force)] fn is_odd(&self) -> bool { !self.is_even() } } @@ -434,90 +434,90 @@ impl Bitwise for $T {} #[cfg(not(test))] impl BitOr<$T,$T> for $T { - #[inline(always)] + #[inline(force)] fn bitor(&self, other: &$T) -> $T { *self | *other } } #[cfg(not(test))] impl BitAnd<$T,$T> for $T { - #[inline(always)] + #[inline(force)] fn bitand(&self, other: &$T) -> $T { *self & *other } } #[cfg(not(test))] impl BitXor<$T,$T> for $T { - #[inline(always)] + #[inline(force)] fn bitxor(&self, other: &$T) -> $T { *self ^ *other } } #[cfg(not(test))] impl Shl<$T,$T> for $T { - #[inline(always)] + #[inline(force)] fn shl(&self, other: &$T) -> $T { *self << *other } } #[cfg(not(test))] impl Shr<$T,$T> for $T { - #[inline(always)] + #[inline(force)] fn shr(&self, other: &$T) -> $T { *self >> *other } } #[cfg(not(test))] impl Not<$T> for $T { - #[inline(always)] + #[inline(force)] fn not(&self) -> $T { !*self } } impl Bounded for $T { - #[inline(always)] + #[inline(force)] fn min_value() -> $T { min_value } - #[inline(always)] + #[inline(force)] fn max_value() -> $T { max_value } } impl Int for $T {} impl Primitive for $T { - #[inline(always)] + #[inline(force)] fn bits() -> uint { bits } - #[inline(always)] + #[inline(force)] fn bytes() -> uint { bits / 8 } } // String conversion functions and impl str -> num /// Parse a string as a number in base 10. -#[inline(always)] +#[inline] pub fn from_str(s: &str) -> Option<$T> { strconv::from_str_common(s, 10u, true, false, false, strconv::ExpNone, false, false) } /// Parse a string as a number in the given base. -#[inline(always)] +#[inline] pub fn from_str_radix(s: &str, radix: uint) -> Option<$T> { strconv::from_str_common(s, radix, true, false, false, strconv::ExpNone, false, false) } /// Parse a byte slice as a number in the given base. -#[inline(always)] +#[inline] pub fn parse_bytes(buf: &[u8], radix: uint) -> Option<$T> { strconv::from_str_bytes_common(buf, radix, true, false, false, strconv::ExpNone, false, false) } impl FromStr for $T { - #[inline(always)] + #[inline] fn from_str(s: &str) -> Option<$T> { from_str(s) } } impl FromStrRadix for $T { - #[inline(always)] + #[inline] fn from_str_radix(s: &str, radix: uint) -> Option<$T> { from_str_radix(s, radix) } @@ -526,7 +526,7 @@ impl FromStrRadix for $T { // String conversion functions and impl num -> str /// Convert to a string as a byte slice in a given base. -#[inline(always)] +#[inline] pub fn to_str_bytes(n: $T, radix: uint, f: &fn(v: &[u8]) -> U) -> U { let (buf, _) = strconv::to_str_bytes_common(&n, radix, false, strconv::SignNeg, strconv::DigAll); @@ -534,7 +534,7 @@ pub fn to_str_bytes(n: $T, radix: uint, f: &fn(v: &[u8]) -> U) -> U { } /// Convert to a string in base 10. -#[inline(always)] +#[inline] pub fn to_str(num: $T) -> ~str { let (buf, _) = strconv::to_str_common(&num, 10u, false, strconv::SignNeg, strconv::DigAll); @@ -542,7 +542,7 @@ pub fn to_str(num: $T) -> ~str { } /// Convert to a string in a given base. -#[inline(always)] +#[inline] pub fn to_str_radix(num: $T, radix: uint) -> ~str { let (buf, _) = strconv::to_str_common(&num, radix, false, strconv::SignNeg, strconv::DigAll); @@ -550,14 +550,14 @@ pub fn to_str_radix(num: $T, radix: uint) -> ~str { } impl ToStr for $T { - #[inline(always)] + #[inline] fn to_str(&self) -> ~str { to_str(*self) } } impl ToStrRadix for $T { - #[inline(always)] + #[inline] fn to_str_radix(&self, radix: uint) -> ~str { to_str_radix(*self, radix) } diff --git a/src/libstd/num/num.rs b/src/libstd/num/num.rs index 91631d3c9b904..6796ebc87fe99 100644 --- a/src/libstd/num/num.rs +++ b/src/libstd/num/num.rs @@ -307,7 +307,7 @@ pub trait Float: Real /// assert_eq!(twenty, 20f32); /// ~~~ /// -#[inline(always)] +#[inline(force)] pub fn cast(n: T) -> U { NumCast::from(n) } @@ -338,28 +338,28 @@ pub trait NumCast { macro_rules! impl_num_cast( ($T:ty, $conv:ident) => ( impl NumCast for $T { - #[inline(always)] + #[inline(force)] fn from(n: N) -> $T { // `$conv` could be generated using `concat_idents!`, but that // macro seems to be broken at the moment n.$conv() } - #[inline(always)] fn to_u8(&self) -> u8 { *self as u8 } - #[inline(always)] fn to_u16(&self) -> u16 { *self as u16 } - #[inline(always)] fn to_u32(&self) -> u32 { *self as u32 } - #[inline(always)] fn to_u64(&self) -> u64 { *self as u64 } - #[inline(always)] fn to_uint(&self) -> uint { *self as uint } - - #[inline(always)] fn to_i8(&self) -> i8 { *self as i8 } - #[inline(always)] fn to_i16(&self) -> i16 { *self as i16 } - #[inline(always)] fn to_i32(&self) -> i32 { *self as i32 } - #[inline(always)] fn to_i64(&self) -> i64 { *self as i64 } - #[inline(always)] fn to_int(&self) -> int { *self as int } - - #[inline(always)] fn to_f32(&self) -> f32 { *self as f32 } - #[inline(always)] fn to_f64(&self) -> f64 { *self as f64 } - #[inline(always)] fn to_float(&self) -> float { *self as float } + #[inline(force)] fn to_u8(&self) -> u8 { *self as u8 } + #[inline(force)] fn to_u16(&self) -> u16 { *self as u16 } + #[inline(force)] fn to_u32(&self) -> u32 { *self as u32 } + #[inline(force)] fn to_u64(&self) -> u64 { *self as u64 } + #[inline(force)] fn to_uint(&self) -> uint { *self as uint } + + #[inline(force)] fn to_i8(&self) -> i8 { *self as i8 } + #[inline(force)] fn to_i16(&self) -> i16 { *self as i16 } + #[inline(force)] fn to_i32(&self) -> i32 { *self as i32 } + #[inline(force)] fn to_i64(&self) -> i64 { *self as i64 } + #[inline(force)] fn to_int(&self) -> int { *self as int } + + #[inline(force)] fn to_f32(&self) -> f32 { *self as f32 } + #[inline(force)] fn to_f64(&self) -> f64 { *self as f64 } + #[inline(force)] fn to_float(&self) -> float { *self as float } } ) ) diff --git a/src/libstd/num/strconv.rs b/src/libstd/num/strconv.rs index 30efe9a392233..8a26db2f40063 100644 --- a/src/libstd/num/strconv.rs +++ b/src/libstd/num/strconv.rs @@ -41,12 +41,12 @@ pub enum SignFormat { SignAll } -#[inline(always)] +#[inline(force)] fn is_NaN(num: &T) -> bool { *num != *num } -#[inline(always)] +#[inline(force)] fn is_inf(num: &T) -> bool { match NumStrConv::inf() { None => false, @@ -54,7 +54,7 @@ fn is_inf(num: &T) -> bool { } } -#[inline(always)] +#[inline(force)] fn is_neg_inf(num: &T) -> bool { match NumStrConv::neg_inf() { None => false, @@ -62,7 +62,7 @@ fn is_neg_inf(num: &T) -> bool { } } -#[inline(always)] +#[inline(force)] fn is_neg_zero>(num: &T) -> bool { let _0: T = Zero::zero(); let _1: T = One::one(); @@ -82,23 +82,23 @@ pub trait NumStrConv { macro_rules! impl_NumStrConv_Floating (($t:ty) => ( impl NumStrConv for $t { - #[inline(always)] + #[inline(force)] fn NaN() -> Option<$t> { Some( 0.0 / 0.0) } - #[inline(always)] + #[inline(force)] fn inf() -> Option<$t> { Some( 1.0 / 0.0) } - #[inline(always)] + #[inline(force)] fn neg_inf() -> Option<$t> { Some(-1.0 / 0.0) } - #[inline(always)] + #[inline(force)] fn neg_zero() -> Option<$t> { Some(-0.0 ) } - #[inline(always)] + #[inline(force)] fn round_to_zero(&self) -> $t { ( if *self < 0.0 { f64::ceil(*self as f64) } else { f64::floor(*self as f64) } ) as $t } - #[inline(always)] + #[inline(force)] fn fractional_part(&self) -> $t { *self - self.round_to_zero() } @@ -107,13 +107,13 @@ macro_rules! impl_NumStrConv_Floating (($t:ty) => ( macro_rules! impl_NumStrConv_Integer (($t:ty) => ( impl NumStrConv for $t { - #[inline(always)] fn NaN() -> Option<$t> { None } - #[inline(always)] fn inf() -> Option<$t> { None } - #[inline(always)] fn neg_inf() -> Option<$t> { None } - #[inline(always)] fn neg_zero() -> Option<$t> { None } + #[inline(force)] fn NaN() -> Option<$t> { None } + #[inline(force)] fn inf() -> Option<$t> { None } + #[inline(force)] fn neg_inf() -> Option<$t> { None } + #[inline(force)] fn neg_zero() -> Option<$t> { None } - #[inline(always)] fn round_to_zero(&self) -> $t { *self } - #[inline(always)] fn fractional_part(&self) -> $t { 0 } + #[inline(force)] fn round_to_zero(&self) -> $t { *self } + #[inline(force)] fn fractional_part(&self) -> $t { 0 } } )) @@ -380,7 +380,7 @@ pub fn to_str_bytes_common+Neg+Rem+Mul>( num: &T, radix: uint, negative_zero: bool, @@ -631,7 +631,7 @@ pub fn from_str_bytes_common+ * Parses a string as a number. This is a wrapper for * `from_str_bytes_common()`, for details see there. */ -#[inline(always)] +#[inline] pub fn from_str_common+Mul+ Sub+Neg+Add+NumStrConv>( buf: &str, radix: uint, negative: bool, fractional: bool, diff --git a/src/libstd/num/uint.rs b/src/libstd/num/uint.rs index bcb97ff5a07f6..58c5b59c58767 100644 --- a/src/libstd/num/uint.rs +++ b/src/libstd/num/uint.rs @@ -29,6 +29,7 @@ uint_module!(uint, int, ::int::bits) /// /// The smallest integer `q` such that `x/y <= q`. /// +#[inline] pub fn div_ceil(x: uint, y: uint) -> uint { let div = x / y; if x % y == 0u { div } @@ -47,6 +48,7 @@ pub fn div_ceil(x: uint, y: uint) -> uint { /// /// The integer `q` closest to `x/y`. /// +#[inline] pub fn div_round(x: uint, y: uint) -> uint { let div = x / y; if x % y * 2u < y { div } @@ -68,6 +70,7 @@ pub fn div_round(x: uint, y: uint) -> uint { /// The smallest integer `q` such that `x/y <= q`. This /// is either `x/y` or `x/y + 1`. /// +#[inline] pub fn div_floor(x: uint, y: uint) -> uint { return x / y; } /// @@ -85,6 +88,7 @@ pub fn div_floor(x: uint, y: uint) -> uint { return x / y; } /// `true` If execution proceeded correctly, `false` if it was interrupted, /// that is if `it` returned `false` at any point. /// +#[inline] pub fn iterate(lo: uint, hi: uint, it: &fn(uint) -> bool) -> bool { let mut i = lo; while i < hi { @@ -95,7 +99,6 @@ pub fn iterate(lo: uint, hi: uint, it: &fn(uint) -> bool) -> bool { } impl iter::Times for uint { - #[inline(always)] /// /// A convenience form for basic iteration. Given a uint `x`, /// `for x.times { ... }` executes the given block x times. @@ -106,6 +109,7 @@ impl iter::Times for uint { /// use with integer literals of inferred integer-type as /// the self-value (eg. `for 100.times { ... }`). /// + #[inline(force)] fn times(&self, it: &fn() -> bool) -> bool { let mut i = *self; while i > 0 { @@ -117,7 +121,7 @@ impl iter::Times for uint { } /// Returns the smallest power of 2 greater than or equal to `n` -#[inline(always)] +#[inline] pub fn next_power_of_two(n: uint) -> uint { let halfbits: uint = sys::size_of::() * 4u; let mut tmp: uint = n - 1u; diff --git a/src/libstd/num/uint_macros.rs b/src/libstd/num/uint_macros.rs index a7aebf1f176c2..630f20ae14554 100644 --- a/src/libstd/num/uint_macros.rs +++ b/src/libstd/num/uint_macros.rs @@ -28,42 +28,42 @@ pub static min_value: $T = 0 as $T; pub static max_value: $T = 0 as $T - 1 as $T; /// Calculates the sum of two numbers -#[inline(always)] +#[inline(force)] pub fn add(x: $T, y: $T) -> $T { x + y } /// Subtracts the second number from the first -#[inline(always)] +#[inline(force)] pub fn sub(x: $T, y: $T) -> $T { x - y } /// Multiplies two numbers together -#[inline(always)] +#[inline(force)] pub fn mul(x: $T, y: $T) -> $T { x * y } /// Divides the first argument by the second argument (using integer division) -#[inline(always)] +#[inline(force)] pub fn div(x: $T, y: $T) -> $T { x / y } /// Calculates the integer remainder when x is divided by y (equivalent to the /// '%' operator) -#[inline(always)] +#[inline(force)] pub fn rem(x: $T, y: $T) -> $T { x % y } /// Returns true iff `x < y` -#[inline(always)] +#[inline(force)] pub fn lt(x: $T, y: $T) -> bool { x < y } /// Returns true iff `x <= y` -#[inline(always)] +#[inline(force)] pub fn le(x: $T, y: $T) -> bool { x <= y } /// Returns true iff `x == y` -#[inline(always)] +#[inline(force)] pub fn eq(x: $T, y: $T) -> bool { x == y } /// Returns true iff `x != y` -#[inline(always)] +#[inline(force)] pub fn ne(x: $T, y: $T) -> bool { x != y } /// Returns true iff `x >= y` -#[inline(always)] +#[inline(force)] pub fn ge(x: $T, y: $T) -> bool { x >= y } /// Returns true iff `x > y` -#[inline(always)] +#[inline(force)] pub fn gt(x: $T, y: $T) -> bool { x > y } -#[inline(always)] +#[inline(force)] /** * Iterate through a range with a given step value. * @@ -99,20 +99,20 @@ pub fn range_step(start: $T, stop: $T, step: $T_SIGNED, it: &fn($T) -> bool) -> return true; } -#[inline(always)] +#[inline(force)] /// Iterate over the range [`lo`..`hi`) pub fn range(lo: $T, hi: $T, it: &fn($T) -> bool) -> bool { range_step(lo, hi, 1 as $T_SIGNED, it) } -#[inline(always)] +#[inline(force)] /// Iterate over the range [`hi`..`lo`) pub fn range_rev(hi: $T, lo: $T, it: &fn($T) -> bool) -> bool { range_step(hi, lo, -1 as $T_SIGNED, it) } /// Computes the bitwise complement -#[inline(always)] +#[inline(force)] pub fn compl(i: $T) -> $T { max_value ^ i } @@ -121,37 +121,37 @@ impl Num for $T {} #[cfg(not(test))] impl Ord for $T { - #[inline(always)] + #[inline(force)] fn lt(&self, other: &$T) -> bool { (*self) < (*other) } - #[inline(always)] + #[inline(force)] fn le(&self, other: &$T) -> bool { (*self) <= (*other) } - #[inline(always)] + #[inline(force)] fn ge(&self, other: &$T) -> bool { (*self) >= (*other) } - #[inline(always)] + #[inline(force)] fn gt(&self, other: &$T) -> bool { (*self) > (*other) } } #[cfg(not(test))] impl Eq for $T { - #[inline(always)] + #[inline(force)] fn eq(&self, other: &$T) -> bool { return (*self) == (*other); } - #[inline(always)] + #[inline(force)] fn ne(&self, other: &$T) -> bool { return (*self) != (*other); } } impl Orderable for $T { - #[inline(always)] + #[inline(force)] fn min(&self, other: &$T) -> $T { if *self < *other { *self } else { *other } } - #[inline(always)] + #[inline(force)] fn max(&self, other: &$T) -> $T { if *self > *other { *self } else { *other } } /// Returns the number constrained within the range `mn <= self <= mx`. - #[inline(always)] + #[inline(force)] fn clamp(&self, mn: &$T, mx: &$T) -> $T { cond!( (*self > *mx) { *mx } @@ -162,51 +162,51 @@ impl Orderable for $T { } impl Zero for $T { - #[inline(always)] + #[inline(force)] fn zero() -> $T { 0 } - #[inline(always)] + #[inline(force)] fn is_zero(&self) -> bool { *self == 0 } } impl One for $T { - #[inline(always)] + #[inline(force)] fn one() -> $T { 1 } } #[cfg(not(test))] impl Add<$T,$T> for $T { - #[inline(always)] + #[inline(force)] fn add(&self, other: &$T) -> $T { *self + *other } } #[cfg(not(test))] impl Sub<$T,$T> for $T { - #[inline(always)] + #[inline(force)] fn sub(&self, other: &$T) -> $T { *self - *other } } #[cfg(not(test))] impl Mul<$T,$T> for $T { - #[inline(always)] + #[inline(force)] fn mul(&self, other: &$T) -> $T { *self * *other } } #[cfg(not(test))] impl Div<$T,$T> for $T { - #[inline(always)] + #[inline(force)] fn div(&self, other: &$T) -> $T { *self / *other } } #[cfg(not(test))] impl Rem<$T,$T> for $T { - #[inline(always)] + #[inline(force)] fn rem(&self, other: &$T) -> $T { *self % *other } } #[cfg(not(test))] impl Neg<$T> for $T { - #[inline(always)] + #[inline(force)] fn neg(&self) -> $T { -*self } } @@ -214,27 +214,27 @@ impl Unsigned for $T {} impl Integer for $T { /// Calculates `div` (`\`) and `rem` (`%`) simultaneously - #[inline(always)] + #[inline(force)] fn div_rem(&self, other: &$T) -> ($T,$T) { (*self / *other, *self % *other) } /// Unsigned integer division. Returns the same result as `div` (`/`). - #[inline(always)] + #[inline(force)] fn div_floor(&self, other: &$T) -> $T { *self / *other } /// Unsigned integer modulo operation. Returns the same result as `rem` (`%`). - #[inline(always)] + #[inline(force)] fn mod_floor(&self, other: &$T) -> $T { *self / *other } /// Calculates `div_floor` and `modulo_floor` simultaneously - #[inline(always)] + #[inline(force)] fn div_mod_floor(&self, other: &$T) -> ($T,$T) { (*self / *other, *self % *other) } /// Calculates the Greatest Common Divisor (GCD) of the number and `other` - #[inline(always)] + #[inline(force)] fn gcd(&self, other: &$T) -> $T { // Use Euclid's algorithm let mut (m, n) = (*self, *other); @@ -247,21 +247,21 @@ impl Integer for $T { } /// Calculates the Lowest Common Multiple (LCM) of the number and `other` - #[inline(always)] + #[inline(force)] fn lcm(&self, other: &$T) -> $T { (*self * *other) / self.gcd(other) } /// Returns `true` if the number can be divided by `other` without leaving a remainder - #[inline(always)] + #[inline(force)] fn is_multiple_of(&self, other: &$T) -> bool { *self % *other == 0 } /// Returns `true` if the number is divisible by `2` - #[inline(always)] + #[inline(force)] fn is_even(&self) -> bool { self.is_multiple_of(&2) } /// Returns `true` if the number is not divisible by `2` - #[inline(always)] + #[inline(force)] fn is_odd(&self) -> bool { !self.is_even() } } @@ -269,45 +269,45 @@ impl Bitwise for $T {} #[cfg(not(test))] impl BitOr<$T,$T> for $T { - #[inline(always)] + #[inline(force)] fn bitor(&self, other: &$T) -> $T { *self | *other } } #[cfg(not(test))] impl BitAnd<$T,$T> for $T { - #[inline(always)] + #[inline(force)] fn bitand(&self, other: &$T) -> $T { *self & *other } } #[cfg(not(test))] impl BitXor<$T,$T> for $T { - #[inline(always)] + #[inline(force)] fn bitxor(&self, other: &$T) -> $T { *self ^ *other } } #[cfg(not(test))] impl Shl<$T,$T> for $T { - #[inline(always)] + #[inline(force)] fn shl(&self, other: &$T) -> $T { *self << *other } } #[cfg(not(test))] impl Shr<$T,$T> for $T { - #[inline(always)] + #[inline(force)] fn shr(&self, other: &$T) -> $T { *self >> *other } } #[cfg(not(test))] impl Not<$T> for $T { - #[inline(always)] + #[inline(force)] fn not(&self) -> $T { !*self } } impl Bounded for $T { - #[inline(always)] + #[inline(force)] fn min_value() -> $T { min_value } - #[inline(always)] + #[inline(force)] fn max_value() -> $T { max_value } } @@ -316,35 +316,35 @@ impl Int for $T {} // String conversion functions and impl str -> num /// Parse a string as a number in base 10. -#[inline(always)] +#[inline] pub fn from_str(s: &str) -> Option<$T> { strconv::from_str_common(s, 10u, false, false, false, strconv::ExpNone, false, false) } /// Parse a string as a number in the given base. -#[inline(always)] +#[inline] pub fn from_str_radix(s: &str, radix: uint) -> Option<$T> { strconv::from_str_common(s, radix, false, false, false, strconv::ExpNone, false, false) } /// Parse a byte slice as a number in the given base. -#[inline(always)] +#[inline] pub fn parse_bytes(buf: &[u8], radix: uint) -> Option<$T> { strconv::from_str_bytes_common(buf, radix, false, false, false, strconv::ExpNone, false, false) } impl FromStr for $T { - #[inline(always)] + #[inline] fn from_str(s: &str) -> Option<$T> { from_str(s) } } impl FromStrRadix for $T { - #[inline(always)] + #[inline] fn from_str_radix(s: &str, radix: uint) -> Option<$T> { from_str_radix(s, radix) } @@ -353,7 +353,7 @@ impl FromStrRadix for $T { // String conversion functions and impl num -> str /// Convert to a string as a byte slice in a given base. -#[inline(always)] +#[inline] pub fn to_str_bytes(n: $T, radix: uint, f: &fn(v: &[u8]) -> U) -> U { let (buf, _) = strconv::to_str_bytes_common(&n, radix, false, strconv::SignNeg, strconv::DigAll); @@ -361,7 +361,7 @@ pub fn to_str_bytes(n: $T, radix: uint, f: &fn(v: &[u8]) -> U) -> U { } /// Convert to a string in base 10. -#[inline(always)] +#[inline] pub fn to_str(num: $T) -> ~str { let (buf, _) = strconv::to_str_common(&num, 10u, false, strconv::SignNeg, strconv::DigAll); @@ -369,7 +369,7 @@ pub fn to_str(num: $T) -> ~str { } /// Convert to a string in a given base. -#[inline(always)] +#[inline] pub fn to_str_radix(num: $T, radix: uint) -> ~str { let (buf, _) = strconv::to_str_common(&num, radix, false, strconv::SignNeg, strconv::DigAll); @@ -377,42 +377,42 @@ pub fn to_str_radix(num: $T, radix: uint) -> ~str { } impl ToStr for $T { - #[inline(always)] + #[inline] fn to_str(&self) -> ~str { to_str(*self) } } impl ToStrRadix for $T { - #[inline(always)] + #[inline] fn to_str_radix(&self, radix: uint) -> ~str { to_str_radix(*self, radix) } } impl Primitive for $T { - #[inline(always)] + #[inline(force)] fn bits() -> uint { bits } - #[inline(always)] + #[inline(force)] fn bytes() -> uint { bits / 8 } } impl BitCount for $T { /// Counts the number of bits set. Wraps LLVM's `ctpop` intrinsic. - #[inline(always)] + #[inline(force)] fn population_count(&self) -> $T { (*self as $T_SIGNED).population_count() as $T } /// Counts the number of leading zeros. Wraps LLVM's `ctlz` intrinsic. - #[inline(always)] + #[inline(force)] fn leading_zeros(&self) -> $T { (*self as $T_SIGNED).leading_zeros() as $T } /// Counts the number of trailing zeros. Wraps LLVM's `cttz` intrinsic. - #[inline(always)] + #[inline(force)] fn trailing_zeros(&self) -> $T { (*self as $T_SIGNED).trailing_zeros() as $T } diff --git a/src/libstd/old_iter.rs b/src/libstd/old_iter.rs index 22ca356fa9b18..ca1458ace9f57 100644 --- a/src/libstd/old_iter.rs +++ b/src/libstd/old_iter.rs @@ -93,7 +93,7 @@ pub trait Buildable { fn build_sized(size: uint, builder: &fn(push: &fn(A))) -> Self; } -#[inline(always)] +#[inline(force)] pub fn _eachi>(this: &IA, blk: &fn(uint, &A) -> bool) -> bool { let mut i = 0; for this.each |a| { @@ -109,7 +109,7 @@ pub fn eachi>(this: &IA, blk: &fn(uint, &A) -> bool) -> bool { _eachi(this, blk) } -#[inline(always)] +#[inline(force)] pub fn all>(this: &IA, blk: &fn(&A) -> bool) -> bool { for this.each |a| { if !blk(a) { @@ -119,7 +119,7 @@ pub fn all>(this: &IA, blk: &fn(&A) -> bool) -> bool { return true; } -#[inline(always)] +#[inline(force)] pub fn any>(this: &IA, blk: &fn(&A) -> bool) -> bool { for this.each |a| { if blk(a) { @@ -129,7 +129,7 @@ pub fn any>(this: &IA, blk: &fn(&A) -> bool) -> bool { return false; } -#[inline(always)] +#[inline(force)] pub fn filter_to_vec>(this: &IA, prd: &fn(&A) -> bool) -> ~[A] { @@ -140,7 +140,7 @@ pub fn filter_to_vec>(this: &IA, } } -#[inline(always)] +#[inline(force)] pub fn map_to_vec>(this: &IA, op: &fn(&A) -> B) -> ~[B] { do vec::build_sized_opt(this.size_hint()) |push| { for this.each |a| { @@ -149,7 +149,7 @@ pub fn map_to_vec>(this: &IA, op: &fn(&A) -> B) -> ~[B] { } } -#[inline(always)] +#[inline(force)] pub fn flat_map_to_vec,IB:BaseIter>(this: &IA, op: &fn(&A) -> IB) -> ~[B] { @@ -162,7 +162,7 @@ pub fn flat_map_to_vec,IB:BaseIter>(this: &IA, } } -#[inline(always)] +#[inline(force)] pub fn foldl>(this: &IA, b0: B, blk: &fn(&B, &A) -> B) -> B { let mut b = b0; @@ -172,12 +172,12 @@ pub fn foldl>(this: &IA, b0: B, blk: &fn(&B, &A) -> B) b } -#[inline(always)] +#[inline(force)] pub fn to_vec>(this: &IA) -> ~[A] { map_to_vec(this, |&x| x) } -#[inline(always)] +#[inline(force)] pub fn contains>(this: &IA, x: &A) -> bool { for this.each |a| { if *a == *x { return true; } @@ -185,7 +185,7 @@ pub fn contains>(this: &IA, x: &A) -> bool { return false; } -#[inline(always)] +#[inline(force)] pub fn count>(this: &IA, x: &A) -> uint { do foldl(this, 0) |count, value| { if *value == *x { @@ -196,7 +196,7 @@ pub fn count>(this: &IA, x: &A) -> uint { } } -#[inline(always)] +#[inline(force)] pub fn position>(this: &IA, f: &fn(&A) -> bool) -> Option { let mut i = 0; @@ -211,7 +211,7 @@ pub fn position>(this: &IA, f: &fn(&A) -> bool) // iter interface, such as would provide "reach" in addition to "each". As is, // it would have to be implemented with foldr, which is too inefficient. -#[inline(always)] +#[inline(force)] pub fn min>(this: &IA) -> A { match do foldl::,IA>(this, None) |a, b| { match a { @@ -226,7 +226,7 @@ pub fn min>(this: &IA) -> A { } } -#[inline(always)] +#[inline(force)] pub fn max>(this: &IA) -> A { match do foldl::,IA>(this, None) |a, b| { match a { @@ -241,7 +241,7 @@ pub fn max>(this: &IA) -> A { } } -#[inline(always)] +#[inline(force)] pub fn find>(this: &IA, f: &fn(&A) -> bool) -> Option { for this.each |i| { @@ -262,7 +262,7 @@ pub fn find>(this: &IA, f: &fn(&A) -> bool) * as an argument a function that will push an element * onto the sequence being constructed. */ -#[inline(always)] +#[inline(force)] pub fn build>(builder: &fn(push: &fn(A))) -> B { Buildable::build_sized(4, builder) } @@ -280,7 +280,7 @@ pub fn build>(builder: &fn(push: &fn(A))) -> B { * as an argument a function that will push an element * onto the sequence being constructed. */ -#[inline(always)] +#[inline(force)] pub fn build_sized_opt>(size: Option, builder: &fn(push: &fn(A))) -> B { Buildable::build_sized(size.get_or_default(4), builder) @@ -290,7 +290,7 @@ pub fn build_sized_opt>(size: Option, /// Applies a function to each element of an iterable and returns the results /// in a sequence built via `BU`. See also `map_to_vec`. -#[inline(always)] +#[inline(force)] pub fn map,U,BU: Buildable>(v: &IT, f: &fn(&T) -> U) -> BU { do build_sized_opt(v.size_hint()) |push| { @@ -306,7 +306,7 @@ pub fn map,U,BU: Buildable>(v: &IT, f: &fn(&T) -> U) * Creates a generic sequence of size `n_elts` and initializes the elements * to the value returned by the function `op`. */ -#[inline(always)] +#[inline(force)] pub fn from_fn>(n_elts: uint, op: InitOp) -> BT { do Buildable::build_sized(n_elts) |push| { let mut i: uint = 0u; @@ -320,7 +320,7 @@ pub fn from_fn>(n_elts: uint, op: InitOp) -> BT { * Creates an immutable vector of size `n_elts` and initializes the elements * to the value `t`. */ -#[inline(always)] +#[inline(force)] pub fn from_elem>(n_elts: uint, t: T) -> BT { do Buildable::build_sized(n_elts) |push| { let mut i: uint = 0; @@ -329,7 +329,7 @@ pub fn from_elem>(n_elts: uint, t: T) -> BT { } /// Appends two generic sequences. -#[inline(always)] +#[inline(force)] pub fn append,BT:Buildable>(lhs: &IT, rhs: &IT) -> BT { let size_opt = lhs.size_hint().chain_ref( @@ -342,7 +342,7 @@ pub fn append,BT:Buildable>(lhs: &IT, rhs: &IT) /// Copies a generic sequence, possibly converting it to a different /// type of sequence. -#[inline(always)] +#[inline(force)] pub fn copy_seq,BT:Buildable>(v: &IT) -> BT { do build_sized_opt(v.size_hint()) |push| { for v.each |x| { push(*x); } diff --git a/src/libstd/option.rs b/src/libstd/option.rs index 2386a779235d5..edbaa9cbeb3a2 100644 --- a/src/libstd/option.rs +++ b/src/libstd/option.rs @@ -89,7 +89,7 @@ impl Ord for Option { } impl> Add, Option> for Option { - #[inline(always)] + #[inline] fn add(&self, other: &Option) -> Option { match (*self, *other) { (None, None) => None, @@ -102,19 +102,19 @@ impl> Add, Option> for Option { impl BaseIter for Option { /// Performs an operation on the contained value by reference - #[inline(always)] + #[inline(force)] fn each<'a>(&'a self, f: &fn(x: &'a T) -> bool) -> bool { match *self { None => true, Some(ref t) => { f(t) } } } - #[inline(always)] + #[inline(force)] fn size_hint(&self) -> Option { if self.is_some() { Some(1) } else { Some(0) } } } impl MutableIter for Option { - #[inline(always)] + #[inline(force)] fn each_mut<'a>(&'a mut self, f: &fn(&'a mut T) -> bool) -> bool { match *self { None => true, Some(ref mut t) => { f(t) } } } @@ -147,17 +147,18 @@ impl ExtendedIter for Option { impl Option { /// Returns true if the option equals `none` + #[inline] pub fn is_none(&const self) -> bool { match *self { None => true, Some(_) => false } } /// Returns true if the option contains some value - #[inline(always)] + #[inline] pub fn is_some(&const self) -> bool { !self.is_none() } /// Update an optional value by optionally running its content through a /// function that returns an option. - #[inline(always)] + #[inline] pub fn chain(self, f: &fn(t: T) -> Option) -> Option { match self { Some(t) => f(t), @@ -166,7 +167,7 @@ impl Option { } /// Returns the leftmost Some() value, or None if both are None. - #[inline(always)] + #[inline] pub fn or(self, optb: Option) -> Option { match self { Some(opta) => Some(opta), @@ -176,7 +177,7 @@ impl Option { /// Update an optional value by optionally running its content by reference /// through a function that returns an option. - #[inline(always)] + #[inline] pub fn chain_ref<'a, U>(&'a self, f: &fn(x: &'a T) -> Option) -> Option { match *self { @@ -186,27 +187,27 @@ impl Option { } /// Maps a `some` value from one type to another by reference - #[inline(always)] + #[inline] pub fn map<'a, U>(&self, f: &fn(&'a T) -> U) -> Option { match *self { Some(ref x) => Some(f(x)), None => None } } /// As `map`, but consumes the option and gives `f` ownership to avoid /// copying. - #[inline(always)] + #[inline] pub fn map_consume(self, f: &fn(v: T) -> U) -> Option { match self { None => None, Some(v) => Some(f(v)) } } /// Applies a function to the contained value or returns a default - #[inline(always)] + #[inline] pub fn map_default<'a, U>(&'a self, def: U, f: &fn(&'a T) -> U) -> U { match *self { None => def, Some(ref t) => f(t) } } /// As `map_default`, but consumes the option and gives `f` /// ownership to avoid copying. - #[inline(always)] + #[inline] pub fn map_consume_default(self, def: U, f: &fn(v: T) -> U) -> U { match self { None => def, Some(v) => f(v) } } @@ -241,7 +242,7 @@ impl Option { Instead, prefer to use pattern matching and handle the `None` case explicitly. */ - #[inline(always)] + #[inline] pub fn get_ref<'a>(&'a self) -> &'a T { match *self { Some(ref x) => x, @@ -263,7 +264,7 @@ impl Option { Instead, prefer to use pattern matching and handle the `None` case explicitly. */ - #[inline(always)] + #[inline] pub fn get_mut_ref<'a>(&'a mut self) -> &'a mut T { match *self { Some(ref mut x) => x, @@ -271,7 +272,7 @@ impl Option { } } - #[inline(always)] + #[inline] pub fn unwrap(self) -> T { /*! Moves a value out of an option type and returns it. @@ -303,7 +304,7 @@ impl Option { * * Fails if the value equals `None`. */ - #[inline(always)] + #[inline] pub fn swap_unwrap(&mut self) -> T { if self.is_none() { fail!("option::swap_unwrap none") } util::replace(self, None).unwrap() @@ -317,7 +318,7 @@ impl Option { * * Fails if the value equals `none` */ - #[inline(always)] + #[inline] pub fn expect(self, reason: &str) -> T { match self { Some(val) => val, @@ -341,7 +342,7 @@ impl Option { Instead, prefer to use pattern matching and handle the `None` case explicitly. */ - #[inline(always)] + #[inline] pub fn get(self) -> T { match self { Some(x) => return x, @@ -350,13 +351,13 @@ impl Option { } /// Returns the contained value or a default - #[inline(always)] + #[inline] pub fn get_or_default(self, def: T) -> T { match self { Some(x) => x, None => def } } /// Applies a function zero or more times until the result is none. - #[inline(always)] + #[inline(force)] pub fn while_some(self, blk: &fn(v: T) -> Option) { let mut opt = self; while opt.is_some() { @@ -367,7 +368,7 @@ impl Option { impl Option { /// Returns the contained value or zero (for this type) - #[inline(always)] + #[inline] pub fn get_or_zero(self) -> T { match self { Some(x) => x, diff --git a/src/libstd/owned.rs b/src/libstd/owned.rs index 3262fb4afdcf6..590d6f6b5bfc3 100644 --- a/src/libstd/owned.rs +++ b/src/libstd/owned.rs @@ -14,20 +14,20 @@ #[cfg(not(test))] impl Eq for ~T { - #[inline(always)] + #[inline(force)] fn eq(&self, other: &~T) -> bool { *(*self) == *(*other) } - #[inline(always)] + #[inline(force)] fn ne(&self, other: &~T) -> bool { *(*self) != *(*other) } } #[cfg(not(test))] impl Ord for ~T { - #[inline(always)] + #[inline(force)] fn lt(&self, other: &~T) -> bool { *(*self) < *(*other) } - #[inline(always)] + #[inline(force)] fn le(&self, other: &~T) -> bool { *(*self) <= *(*other) } - #[inline(always)] + #[inline(force)] fn ge(&self, other: &~T) -> bool { *(*self) >= *(*other) } - #[inline(always)] + #[inline(force)] fn gt(&self, other: &~T) -> bool { *(*self) > *(*other) } } diff --git a/src/libstd/path.rs b/src/libstd/path.rs index a551b9bf3c0b3..7cdea626f8ae4 100644 --- a/src/libstd/path.rs +++ b/src/libstd/path.rs @@ -904,7 +904,7 @@ pub mod windows { use libc; use option::{None, Option, Some}; - #[inline(always)] + #[inline] pub fn is_sep(u: u8) -> bool { u == '/' as u8 || u == '\\' as u8 } diff --git a/src/libstd/ptr.rs b/src/libstd/ptr.rs index c8e2f58d80190..57a5f75547c01 100644 --- a/src/libstd/ptr.rs +++ b/src/libstd/ptr.rs @@ -21,31 +21,31 @@ use unstable::intrinsics; use uint; /// Calculate the offset from a pointer -#[inline(always)] +#[inline(force)] pub fn offset(ptr: *T, count: uint) -> *T { (ptr as uint + count * sys::size_of::()) as *T } /// Calculate the offset from a const pointer -#[inline(always)] +#[inline(force)] pub fn const_offset(ptr: *const T, count: uint) -> *const T { (ptr as uint + count * sys::size_of::()) as *T } /// Calculate the offset from a mut pointer -#[inline(always)] +#[inline(force)] pub fn mut_offset(ptr: *mut T, count: uint) -> *mut T { (ptr as uint + count * sys::size_of::()) as *mut T } /// Return the offset of the first null pointer in `buf`. -#[inline(always)] +#[inline(force)] pub unsafe fn buf_len(buf: **T) -> uint { position(buf, |i| *i == null()) } /// Return the first offset `i` such that `f(buf[i]) == true`. -#[inline(always)] +#[inline(force)] pub unsafe fn position(buf: *T, f: &fn(&T) -> bool) -> uint { let mut i = 0; loop { @@ -55,19 +55,19 @@ pub unsafe fn position(buf: *T, f: &fn(&T) -> bool) -> uint { } /// Create an unsafe null pointer -#[inline(always)] +#[inline(force)] pub fn null() -> *T { 0 as *T } /// Create an unsafe mutable null pointer -#[inline(always)] +#[inline(force)] pub fn mut_null() -> *mut T { 0 as *mut T } /// Returns true if the pointer is equal to the null pointer. -#[inline(always)] +#[inline(force)] pub fn is_null(ptr: *const T) -> bool { ptr == null() } /// Returns true if the pointer is not equal to the null pointer. -#[inline(always)] +#[inline(force)] pub fn is_not_null(ptr: *const T) -> bool { !is_null(ptr) } /** @@ -76,7 +76,7 @@ pub fn is_not_null(ptr: *const T) -> bool { !is_null(ptr) } * Copies `count` elements (not bytes) from `src` to `dst`. The source * and destination may overlap. */ -#[inline(always)] +#[inline(force)] #[cfg(target_word_size = "32", stage0)] pub unsafe fn copy_memory(dst: *mut T, src: *const T, count: uint) { use unstable::intrinsics::memmove32; @@ -90,14 +90,14 @@ pub unsafe fn copy_memory(dst: *mut T, src: *const T, count: uint) { * Copies `count` elements (not bytes) from `src` to `dst`. The source * and destination may overlap. */ -#[inline(always)] +#[inline(force)] #[cfg(target_word_size = "32", not(stage0))] pub unsafe fn copy_memory(dst: *mut T, src: *const T, count: uint) { use unstable::intrinsics::memmove32; memmove32(dst, src as *T, count as u32); } -#[inline(always)] +#[inline(force)] #[cfg(target_word_size = "64", stage0)] pub unsafe fn copy_memory(dst: *mut T, src: *const T, count: uint) { use unstable::intrinsics::memmove64; @@ -111,14 +111,14 @@ pub unsafe fn copy_memory(dst: *mut T, src: *const T, count: uint) { * Copies `count` elements (not bytes) from `src` to `dst`. The source * and destination may overlap. */ -#[inline(always)] +#[inline(force)] #[cfg(target_word_size = "64", not(stage0))] pub unsafe fn copy_memory(dst: *mut T, src: *const T, count: uint) { use unstable::intrinsics::memmove64; memmove64(dst, src as *T, count as u64); } -#[inline(always)] +#[inline(force)] #[cfg(target_word_size = "32", stage0)] pub unsafe fn copy_nonoverlapping_memory(dst: *mut T, src: *const T, count: uint) { use unstable::intrinsics::memmove32; @@ -133,14 +133,14 @@ pub unsafe fn copy_nonoverlapping_memory(dst: *mut T, src: *const T, count: u * Copies `count` elements (not bytes) from `src` to `dst`. The source * and destination may overlap. */ -#[inline(always)] +#[inline(force)] #[cfg(target_word_size = "32", not(stage0))] pub unsafe fn copy_nonoverlapping_memory(dst: *mut T, src: *const T, count: uint) { use unstable::intrinsics::memcpy32; memcpy32(dst, src as *T, count as u32); } -#[inline(always)] +#[inline(force)] #[cfg(target_word_size = "64", stage0)] pub unsafe fn copy_nonoverlapping_memory(dst: *mut T, src: *const T, count: uint) { use unstable::intrinsics::memmove64; @@ -155,7 +155,7 @@ pub unsafe fn copy_nonoverlapping_memory(dst: *mut T, src: *const T, count: u * Copies `count` elements (not bytes) from `src` to `dst`. The source * and destination may overlap. */ -#[inline(always)] +#[inline(force)] #[cfg(target_word_size = "64", not(stage0))] pub unsafe fn copy_nonoverlapping_memory(dst: *mut T, src: *const T, count: uint) { use unstable::intrinsics::memcpy64; @@ -166,7 +166,7 @@ pub unsafe fn copy_nonoverlapping_memory(dst: *mut T, src: *const T, count: u * Invokes memset on the specified pointer, setting `count` bytes of memory * starting at `dst` to `c`. */ -#[inline(always)] +#[inline(force)] #[cfg(target_word_size = "32", not(stage0))] pub unsafe fn set_memory(dst: *mut T, c: u8, count: uint) { use unstable::intrinsics::memset32; @@ -177,7 +177,7 @@ pub unsafe fn set_memory(dst: *mut T, c: u8, count: uint) { * Invokes memset on the specified pointer, setting `count` bytes of memory * starting at `dst` to `c`. */ -#[inline(always)] +#[inline(force)] #[cfg(target_word_size = "64", not(stage0))] pub unsafe fn set_memory(dst: *mut T, c: u8, count: uint) { use unstable::intrinsics::memset64; @@ -208,26 +208,26 @@ pub unsafe fn swap_ptr(x: *mut T, y: *mut T) { * Replace the value at a mutable location with a new one, returning the old * value, without deinitialising or copying either one. */ -#[inline(always)] +#[inline(force)] pub unsafe fn replace_ptr(dest: *mut T, mut src: T) -> T { swap_ptr(dest, &mut src); src } /// Transform a region pointer - &T - to an unsafe pointer - *T. -#[inline(always)] +#[inline(force)] pub fn to_unsafe_ptr(thing: &T) -> *T { thing as *T } /// Transform a const region pointer - &const T - to a const unsafe pointer - *const T. -#[inline(always)] +#[inline(force)] pub fn to_const_unsafe_ptr(thing: &const T) -> *const T { thing as *const T } /// Transform a mutable region pointer - &mut T - to a mutable unsafe pointer - *mut T. -#[inline(always)] +#[inline(force)] pub fn to_mut_unsafe_ptr(thing: &mut T) -> *mut T { thing as *mut T } @@ -283,11 +283,11 @@ pub trait RawPtr { /// Extension methods for immutable pointers impl RawPtr for *T { /// Returns true if the pointer is equal to the null pointer. - #[inline(always)] + #[inline(force)] fn is_null(&const self) -> bool { is_null(*self) } /// Returns true if the pointer is not equal to the null pointer. - #[inline(always)] + #[inline(force)] fn is_not_null(&const self) -> bool { is_not_null(*self) } /// @@ -300,7 +300,7 @@ impl RawPtr for *T { /// that this is still an unsafe operation because the returned value could /// be pointing to invalid memory. /// - #[inline(always)] + #[inline(force)] unsafe fn to_option(&const self) -> Option<&T> { if self.is_null() { None } else { Some(cast::transmute(*self)) @@ -308,18 +308,18 @@ impl RawPtr for *T { } /// Calculates the offset from a pointer. - #[inline(always)] + #[inline(force)] fn offset(&self, count: uint) -> *T { offset(*self, count) } } /// Extension methods for mutable pointers impl RawPtr for *mut T { /// Returns true if the pointer is equal to the null pointer. - #[inline(always)] + #[inline(force)] fn is_null(&const self) -> bool { is_null(*self) } /// Returns true if the pointer is not equal to the null pointer. - #[inline(always)] + #[inline(force)] fn is_not_null(&const self) -> bool { is_not_null(*self) } /// @@ -332,7 +332,7 @@ impl RawPtr for *mut T { /// that this is still an unsafe operation because the returned value could /// be pointing to invalid memory. /// - #[inline(always)] + #[inline(force)] unsafe fn to_option(&const self) -> Option<&T> { if self.is_null() { None } else { Some(cast::transmute(*self)) @@ -340,37 +340,37 @@ impl RawPtr for *mut T { } /// Calculates the offset from a mutable pointer. - #[inline(always)] + #[inline(force)] fn offset(&self, count: uint) -> *mut T { mut_offset(*self, count) } } // Equality for pointers #[cfg(not(test))] impl Eq for *const T { - #[inline(always)] + #[inline(force)] fn eq(&self, other: &*const T) -> bool { (*self as uint) == (*other as uint) } - #[inline(always)] + #[inline(force)] fn ne(&self, other: &*const T) -> bool { !self.eq(other) } } // Comparison for pointers #[cfg(not(test))] impl Ord for *const T { - #[inline(always)] + #[inline(force)] fn lt(&self, other: &*const T) -> bool { (*self as uint) < (*other as uint) } - #[inline(always)] + #[inline(force)] fn le(&self, other: &*const T) -> bool { (*self as uint) <= (*other as uint) } - #[inline(always)] + #[inline(force)] fn ge(&self, other: &*const T) -> bool { (*self as uint) >= (*other as uint) } - #[inline(always)] + #[inline(force)] fn gt(&self, other: &*const T) -> bool { (*self as uint) > (*other as uint) } diff --git a/src/libstd/rand.rs b/src/libstd/rand.rs index b763c1c2d7617..ee672fc024835 100644 --- a/src/libstd/rand.rs +++ b/src/libstd/rand.rs @@ -450,7 +450,7 @@ pub trait RngUtil { /// Extension methods for random number generators impl RngUtil for R { /// Return a random value for a Rand type - #[inline(always)] + #[inline] fn gen(&mut self) -> T { Rand::rand(self) } @@ -761,7 +761,7 @@ impl IsaacRng { } impl Rng for IsaacRng { - #[inline(always)] + #[inline] fn next(&mut self) -> u32 { if self.cnt == 0 { // make some more numbers @@ -861,7 +861,7 @@ pub fn task_rng() -> @@mut IsaacRng { // Allow direct chaining with `task_rng` impl Rng for @@mut R { - #[inline(always)] + #[inline] fn next(&mut self) -> u32 { match *self { @@ref mut r => r.next() diff --git a/src/libstd/rand/distributions.rs b/src/libstd/rand/distributions.rs index f08d967cbe022..5b3e64f1c6a1f 100644 --- a/src/libstd/rand/distributions.rs +++ b/src/libstd/rand/distributions.rs @@ -26,7 +26,7 @@ use rand::{Rng,Rand}; mod ziggurat_tables; // inlining should mean there is no performance penalty for this -#[inline(always)] +#[inline(force)] fn ziggurat(rng: &mut R, center_u: bool, X: ziggurat_tables::ZigTable, @@ -77,11 +77,11 @@ pub struct StandardNormal(f64); impl Rand for StandardNormal { fn rand(rng: &mut R) -> StandardNormal { - #[inline(always)] + #[inline(force)] fn pdf(x: f64) -> f64 { f64::exp((-x*x/2.0) as f64) as f64 } - #[inline(always)] + #[inline(force)] fn zero_case(rng: &mut R, u: f64) -> f64 { // compute a random number in the tail by hand @@ -131,11 +131,11 @@ pub struct Exp1(f64); impl Rand for Exp1 { #[inline] fn rand(rng: &mut R) -> Exp1 { - #[inline(always)] + #[inline(force)] fn pdf(x: f64) -> f64 { f64::exp(-x) } - #[inline(always)] + #[inline(force)] fn zero_case(rng: &mut R, _u: f64) -> f64 { ziggurat_tables::ZIG_EXP_R - f64::ln(rng.gen()) } diff --git a/src/libstd/reflect.rs b/src/libstd/reflect.rs index 1eb3d3a0daaae..d276abf0c8b3e 100644 --- a/src/libstd/reflect.rs +++ b/src/libstd/reflect.rs @@ -35,7 +35,7 @@ pub trait MovePtr { } /// Helper function for alignment calculation. -#[inline(always)] +#[inline] pub fn align(size: uint, align: uint) -> uint { ((size + align) - 1u) & !(align - 1u) } @@ -49,26 +49,26 @@ pub fn MovePtrAdaptor(v: V) -> MovePtrAdaptor { } impl MovePtrAdaptor { - #[inline(always)] + #[inline] pub fn bump(&self, sz: uint) { do self.inner.move_ptr() |p| { ((p as uint) + sz) as *c_void }; } - #[inline(always)] + #[inline] pub fn align(&self, a: uint) { do self.inner.move_ptr() |p| { align(p as uint, a) as *c_void }; } - #[inline(always)] + #[inline] pub fn align_to(&self) { self.align(sys::min_align_of::()); } - #[inline(always)] + #[inline] pub fn bump_past(&self) { self.bump(sys::size_of::()); } diff --git a/src/libstd/repr.rs b/src/libstd/repr.rs index 14bec48782ff3..b64c1c5c8b038 100644 --- a/src/libstd/repr.rs +++ b/src/libstd/repr.rs @@ -162,7 +162,7 @@ pub fn ReprVisitor(ptr: *c_void, writer: @Writer) -> ReprVisitor { } impl MovePtr for ReprVisitor { - #[inline(always)] + #[inline] fn move_ptr(&self, adjustment: &fn(*c_void) -> *c_void) { *self.ptr = adjustment(*self.ptr); } @@ -177,7 +177,7 @@ impl MovePtr for ReprVisitor { impl ReprVisitor { // Various helpers for the TyVisitor impl - #[inline(always)] + #[inline] pub fn get(&self, f: &fn(&T)) -> bool { unsafe { f(transmute::<*c_void,&T>(*self.ptr)); @@ -185,12 +185,12 @@ impl ReprVisitor { true } - #[inline(always)] + #[inline] pub fn visit_inner(&self, inner: *TyDesc) -> bool { self.visit_ptr_inner(*self.ptr, inner) } - #[inline(always)] + #[inline] pub fn visit_ptr_inner(&self, ptr: *c_void, inner: *TyDesc) -> bool { unsafe { let u = ReprVisitor(ptr, self.writer); @@ -200,7 +200,7 @@ impl ReprVisitor { } } - #[inline(always)] + #[inline] pub fn write(&self) -> bool { do self.get |v:&T| { v.write_repr(self.writer); diff --git a/src/libstd/result.rs b/src/libstd/result.rs index 8f7a0015bcf15..fea4491e232e5 100644 --- a/src/libstd/result.rs +++ b/src/libstd/result.rs @@ -37,7 +37,7 @@ pub enum Result { * * If the result is an error */ -#[inline(always)] +#[inline] pub fn get(res: &Result) -> T { match *res { Ok(ref t) => copy *t, @@ -53,7 +53,7 @@ pub fn get(res: &Result) -> T { * * If the result is an error */ -#[inline(always)] +#[inline] pub fn get_ref<'a, T, U>(res: &'a Result) -> &'a T { match *res { Ok(ref t) => t, @@ -69,7 +69,7 @@ pub fn get_ref<'a, T, U>(res: &'a Result) -> &'a T { * * If the result is not an error */ -#[inline(always)] +#[inline] pub fn get_err(res: &Result) -> U { match *res { Err(ref u) => copy *u, @@ -78,7 +78,7 @@ pub fn get_err(res: &Result) -> U { } /// Returns true if the result is `ok` -#[inline(always)] +#[inline] pub fn is_ok(res: &Result) -> bool { match *res { Ok(_) => true, @@ -87,7 +87,7 @@ pub fn is_ok(res: &Result) -> bool { } /// Returns true if the result is `err` -#[inline(always)] +#[inline] pub fn is_err(res: &Result) -> bool { !is_ok(res) } @@ -98,7 +98,7 @@ pub fn is_err(res: &Result) -> bool { * `ok` result variants are converted to `either::right` variants, `err` * result variants are converted to `either::left`. */ -#[inline(always)] +#[inline] pub fn to_either(res: &Result) -> Either { match *res { @@ -121,7 +121,7 @@ pub fn to_either(res: &Result) * ok(parse_bytes(buf)) * } */ -#[inline(always)] +#[inline] pub fn chain(res: Result, op: &fn(T) -> Result) -> Result { match res { @@ -138,7 +138,7 @@ pub fn chain(res: Result, op: &fn(T) * immediately returned. This function can be used to pass through a * successful result while handling an error. */ -#[inline(always)] +#[inline] pub fn chain_err( res: Result, op: &fn(t: V) -> Result) @@ -163,7 +163,7 @@ pub fn chain_err( * print_buf(buf) * } */ -#[inline(always)] +#[inline(force)] pub fn iter(res: &Result, f: &fn(&T)) { match *res { Ok(ref t) => f(t), @@ -179,7 +179,7 @@ pub fn iter(res: &Result, f: &fn(&T)) { * This function can be used to pass through a successful result while * handling an error. */ -#[inline(always)] +#[inline(force)] pub fn iter_err(res: &Result, f: &fn(&E)) { match *res { Ok(_) => (), @@ -201,7 +201,7 @@ pub fn iter_err(res: &Result, f: &fn(&E)) { * parse_bytes(buf) * } */ -#[inline(always)] +#[inline] pub fn map(res: &Result, op: &fn(&T) -> U) -> Result { match *res { @@ -218,7 +218,7 @@ pub fn map(res: &Result, op: &fn(&T) -> U) * is immediately returned. This function can be used to pass through a * successful result while handling an error. */ -#[inline(always)] +#[inline] pub fn map_err(res: &Result, op: &fn(&E) -> F) -> Result { match *res { @@ -228,53 +228,53 @@ pub fn map_err(res: &Result, op: &fn(&E) -> F) } impl Result { - #[inline(always)] + #[inline] pub fn get_ref<'a>(&'a self) -> &'a T { get_ref(self) } - #[inline(always)] + #[inline] pub fn is_ok(&self) -> bool { is_ok(self) } - #[inline(always)] + #[inline] pub fn is_err(&self) -> bool { is_err(self) } - #[inline(always)] + #[inline] pub fn iter(&self, f: &fn(&T)) { iter(self, f) } - #[inline(always)] + #[inline] pub fn iter_err(&self, f: &fn(&E)) { iter_err(self, f) } - #[inline(always)] + #[inline] pub fn unwrap(self) -> T { unwrap(self) } - #[inline(always)] + #[inline] pub fn unwrap_err(self) -> E { unwrap_err(self) } - #[inline(always)] + #[inline] pub fn chain(self, op: &fn(T) -> Result) -> Result { chain(self, op) } - #[inline(always)] + #[inline] pub fn chain_err(self, op: &fn(E) -> Result) -> Result { chain_err(self, op) } } impl Result { - #[inline(always)] + #[inline] pub fn get(&self) -> T { get(self) } - #[inline(always)] + #[inline] pub fn map_err(&self, op: &fn(&E) -> F) -> Result { map_err(self, op) } } impl Result { - #[inline(always)] + #[inline] pub fn get_err(&self) -> E { get_err(self) } - #[inline(always)] + #[inline] pub fn map(&self, op: &fn(&T) -> U) -> Result { map(self, op) } @@ -297,7 +297,7 @@ impl Result { * assert!(incd == ~[2u, 3u, 4u]); * } */ -#[inline(always)] +#[inline(force)] pub fn map_vec( ts: &[T], op: &fn(&T) -> Result) -> Result<~[V],U> { @@ -311,7 +311,7 @@ pub fn map_vec( return Ok(vs); } -#[inline(always)] +#[inline] #[allow(missing_doc)] pub fn map_opt( o_t: &Option, op: &fn(&T) -> Result) -> Result,U> { @@ -334,7 +334,7 @@ pub fn map_opt( * used in 'careful' code contexts where it is both appropriate and easy * to accommodate an error like the vectors being of different lengths. */ -#[inline(always)] +#[inline(force)] pub fn map_vec2(ss: &[S], ts: &[T], op: &fn(&S,&T) -> Result) -> Result<~[V],U> { @@ -357,7 +357,7 @@ pub fn map_vec2(ss: &[S], ts: &[T], * error. This could be implemented using `map_zip()` but it is more efficient * on its own as no result vector is built. */ -#[inline(always)] +#[inline(force)] pub fn iter_vec2(ss: &[S], ts: &[T], op: &fn(&S,&T) -> Result<(),U>) -> Result<(),U> { @@ -375,7 +375,7 @@ pub fn iter_vec2(ss: &[S], ts: &[T], } /// Unwraps a result, assuming it is an `ok(T)` -#[inline(always)] +#[inline] pub fn unwrap(res: Result) -> T { match res { Ok(t) => t, @@ -384,7 +384,7 @@ pub fn unwrap(res: Result) -> T { } /// Unwraps a result, assuming it is an `err(U)` -#[inline(always)] +#[inline] pub fn unwrap_err(res: Result) -> U { match res { Err(u) => u, diff --git a/src/libstd/rt/context.rs b/src/libstd/rt/context.rs index d5ca8473ceeac..5b0ad02b196c8 100644 --- a/src/libstd/rt/context.rs +++ b/src/libstd/rt/context.rs @@ -207,7 +207,7 @@ fn align_down(sp: *mut uint) -> *mut uint { } // XXX: ptr::offset is positive ints only -#[inline(always)] +#[inline(force)] pub fn mut_offset(ptr: *mut T, count: int) -> *mut T { use core::sys::size_of; (ptr as int + count * (size_of::() as int)) as *mut T diff --git a/src/libstd/str.rs b/src/libstd/str.rs index da9ee21583dd9..b2354a604b169 100644 --- a/src/libstd/str.rs +++ b/src/libstd/str.rs @@ -92,21 +92,21 @@ pub fn from_bytes_slice<'a>(vector: &'a [u8]) -> &'a str { } /// Copy a slice into a new unique str -#[inline(always)] +#[inline] pub fn to_owned(s: &str) -> ~str { unsafe { raw::slice_bytes_owned(s, 0, len(s)) } } impl ToStr for ~str { - #[inline(always)] + #[inline] fn to_str(&self) -> ~str { to_owned(*self) } } impl<'self> ToStr for &'self str { - #[inline(always)] + #[inline] fn to_str(&self) -> ~str { to_owned(*self) } } impl ToStr for @str { - #[inline(always)] + #[inline] fn to_str(&self) -> ~str { to_owned(*self) } } @@ -197,7 +197,7 @@ pub fn from_chars(chs: &[char]) -> ~str { } /// Appends a string slice to the back of a string, without overallocating -#[inline(always)] +#[inline] pub fn push_str_no_overallocate(lhs: &mut ~str, rhs: &str) { unsafe { let llen = lhs.len(); @@ -215,7 +215,7 @@ pub fn push_str_no_overallocate(lhs: &mut ~str, rhs: &str) { } /// Appends a string slice to the back of a string -#[inline(always)] +#[inline] pub fn push_str(lhs: &mut ~str, rhs: &str) { unsafe { let llen = lhs.len(); @@ -233,7 +233,7 @@ pub fn push_str(lhs: &mut ~str, rhs: &str) { } /// Concatenate two strings together -#[inline(always)] +#[inline] pub fn append(lhs: ~str, rhs: &str) -> ~str { let mut v = lhs; push_str_no_overallocate(&mut v, rhs); @@ -241,15 +241,19 @@ pub fn append(lhs: ~str, rhs: &str) -> ~str { } /// Concatenate a vector of strings +#[inline] pub fn concat(v: &[~str]) -> ~str { v.concat() } /// Concatenate a vector of strings +#[inline] pub fn concat_slices(v: &[&str]) -> ~str { v.concat() } /// Concatenate a vector of strings, placing a given separator between each +#[inline] pub fn connect(v: &[~str], sep: &str) -> ~str { v.connect(sep) } /// Concatenate a vector of strings, placing a given separator between each +#[inline] pub fn connect_slices(v: &[&str], sep: &str) -> ~str { v.connect(sep) } #[allow(missing_doc)] @@ -574,7 +578,7 @@ pub fn to_bytes(s: &str) -> ~[u8] { } /// Work with the string as a byte slice, not including trailing null. -#[inline(always)] +#[inline] pub fn byte_slice(s: &str, f: &fn(v: &[u8]) -> T) -> T { do as_buf(s) |p,n| { unsafe { vec::raw::buf_as_slice(p, n-1u, f) } @@ -583,7 +587,7 @@ pub fn byte_slice(s: &str, f: &fn(v: &[u8]) -> T) -> T { /// Work with the string as a byte slice, not including trailing null, without /// a callback. -#[inline(always)] +#[inline] pub fn byte_slice_no_callback<'a>(s: &'a str) -> &'a [u8] { unsafe { cast::transmute(s) @@ -1113,37 +1117,37 @@ fn gt(a: &str, b: &str) -> bool { #[cfg(not(test))] impl<'self> Eq for &'self str { - #[inline(always)] + #[inline(force)] fn eq(&self, other: & &'self str) -> bool { eq_slice((*self), (*other)) } - #[inline(always)] + #[inline(force)] fn ne(&self, other: & &'self str) -> bool { !(*self).eq(other) } } #[cfg(not(test))] impl Eq for ~str { - #[inline(always)] + #[inline(force)] fn eq(&self, other: &~str) -> bool { eq_slice((*self), (*other)) } - #[inline(always)] + #[inline(force)] fn ne(&self, other: &~str) -> bool { !(*self).eq(other) } } #[cfg(not(test))] impl Eq for @str { - #[inline(always)] + #[inline(force)] fn eq(&self, other: &@str) -> bool { eq_slice((*self), (*other)) } - #[inline(always)] + #[inline(force)] fn ne(&self, other: &@str) -> bool { !(*self).eq(other) } } #[cfg(not(test))] impl<'self> TotalEq for &'self str { - #[inline(always)] + #[inline(force)] fn equals(&self, other: & &'self str) -> bool { eq_slice((*self), (*other)) } @@ -1151,7 +1155,7 @@ impl<'self> TotalEq for &'self str { #[cfg(not(test))] impl TotalEq for ~str { - #[inline(always)] + #[inline(force)] fn equals(&self, other: &~str) -> bool { eq_slice((*self), (*other)) } @@ -1159,7 +1163,7 @@ impl TotalEq for ~str { #[cfg(not(test))] impl TotalEq for @str { - #[inline(always)] + #[inline(force)] fn equals(&self, other: &@str) -> bool { eq_slice((*self), (*other)) } @@ -1167,43 +1171,43 @@ impl TotalEq for @str { #[cfg(not(test))] impl Ord for ~str { - #[inline(always)] + #[inline(force)] fn lt(&self, other: &~str) -> bool { lt((*self), (*other)) } - #[inline(always)] + #[inline(force)] fn le(&self, other: &~str) -> bool { le((*self), (*other)) } - #[inline(always)] + #[inline(force)] fn ge(&self, other: &~str) -> bool { ge((*self), (*other)) } - #[inline(always)] + #[inline(force)] fn gt(&self, other: &~str) -> bool { gt((*self), (*other)) } } #[cfg(not(test))] impl<'self> Ord for &'self str { - #[inline(always)] + #[inline(force)] fn lt(&self, other: & &'self str) -> bool { lt((*self), (*other)) } - #[inline(always)] + #[inline(force)] fn le(&self, other: & &'self str) -> bool { le((*self), (*other)) } - #[inline(always)] + #[inline(force)] fn ge(&self, other: & &'self str) -> bool { ge((*self), (*other)) } - #[inline(always)] + #[inline(force)] fn gt(&self, other: & &'self str) -> bool { gt((*self), (*other)) } } #[cfg(not(test))] impl Ord for @str { - #[inline(always)] + #[inline(force)] fn lt(&self, other: &@str) -> bool { lt((*self), (*other)) } - #[inline(always)] + #[inline(force)] fn le(&self, other: &@str) -> bool { le((*self), (*other)) } - #[inline(always)] + #[inline(force)] fn ge(&self, other: &@str) -> bool { ge((*self), (*other)) } - #[inline(always)] + #[inline(force)] fn gt(&self, other: &@str) -> bool { gt((*self), (*other)) } } #[cfg(not(test))] impl<'self> Equiv<~str> for &'self str { - #[inline(always)] + #[inline(force)] fn equiv(&self, other: &~str) -> bool { eq_slice(*self, *other) } } @@ -1238,13 +1242,13 @@ pub fn map(ss: &str, ff: &fn(char) -> char) -> ~str { } /// Iterate over the bytes in a string -#[inline(always)] +#[inline(force)] pub fn each(s: &str, it: &fn(u8) -> bool) -> bool { eachi(s, |_i, b| it(b)) } /// Iterate over the bytes in a string, with indices -#[inline(always)] +#[inline(force)] pub fn eachi(s: &str, it: &fn(uint, u8) -> bool) -> bool { let mut pos = 0; let len = s.len(); @@ -1257,13 +1261,13 @@ pub fn eachi(s: &str, it: &fn(uint, u8) -> bool) -> bool { } /// Iterate over the bytes in a string in reverse -#[inline(always)] +#[inline(force)] pub fn each_reverse(s: &str, it: &fn(u8) -> bool) -> bool { eachi_reverse(s, |_i, b| it(b) ) } /// Iterate over the bytes in a string in reverse, with indices -#[inline(always)] +#[inline(force)] pub fn eachi_reverse(s: &str, it: &fn(uint, u8) -> bool) -> bool { let mut pos = s.len(); while pos > 0 { @@ -1274,7 +1278,7 @@ pub fn eachi_reverse(s: &str, it: &fn(uint, u8) -> bool) -> bool { } /// Iterate over each char of a string, without allocating -#[inline(always)] +#[inline(force)] pub fn each_char(s: &str, it: &fn(char) -> bool) -> bool { let mut i = 0; let len = len(s); @@ -1287,7 +1291,7 @@ pub fn each_char(s: &str, it: &fn(char) -> bool) -> bool { } /// Iterates over the chars in a string, with indices -#[inline(always)] +#[inline(force)] pub fn each_chari(s: &str, it: &fn(uint, char) -> bool) -> bool { let mut pos = 0; let mut ch_pos = 0u; @@ -1302,13 +1306,13 @@ pub fn each_chari(s: &str, it: &fn(uint, char) -> bool) -> bool { } /// Iterates over the chars in a string in reverse -#[inline(always)] +#[inline(force)] pub fn each_char_reverse(s: &str, it: &fn(char) -> bool) -> bool { each_chari_reverse(s, |_, c| it(c)) } /// Iterates over the chars in a string in reverse, with indices -#[inline(always)] +#[inline(force)] pub fn each_chari_reverse(s: &str, it: &fn(uint, char) -> bool) -> bool { let mut pos = s.len(); let mut ch_pos = s.char_len(); @@ -1787,7 +1791,7 @@ Section: String properties */ /// Returns true if the string has length 0 -#[inline(always)] +#[inline(force)] pub fn is_empty(s: &str) -> bool { len(s) == 0u } /** @@ -1809,13 +1813,13 @@ fn is_alphanumeric(s: &str) -> bool { } /// Returns the string length/size in bytes not counting the null terminator -#[inline(always)] +#[inline(force)] pub fn len(s: &str) -> uint { do as_buf(s) |_p, n| { n - 1u } } /// Returns the number of characters that a string holds -#[inline(always)] +#[inline(force)] pub fn char_len(s: &str) -> uint { count_chars(s, 0u, len(s)) } /* @@ -2259,7 +2263,7 @@ impl<'self> StrUtil for &'self str { /** * Deprecated. Use the `as_c_str` method on strings instead. */ -#[inline(always)] +#[inline] pub fn as_c_str(s: &str, f: &fn(*libc::c_char) -> T) -> T { s.as_c_str(f) } @@ -2272,7 +2276,7 @@ pub fn as_c_str(s: &str, f: &fn(*libc::c_char) -> T) -> T { * indexable area for a null byte, as is the case in slices pointing * to full strings, or suffixes of them. */ -#[inline(always)] +#[inline] pub fn as_buf(s: &str, f: &fn(*u8, uint) -> T) -> T { unsafe { let v : *(*u8,uint) = transmute(&s); @@ -2296,7 +2300,7 @@ pub fn as_buf(s: &str, f: &fn(*u8, uint) -> T) -> T { * assert!(subslice_offset(string, lines[2]) == 4); // &"c" * ~~~ */ -#[inline(always)] +#[inline] pub fn subslice_offset(outer: &str, inner: &str) -> uint { do as_buf(outer) |a, a_len| { do as_buf(inner) |b, b_len| { @@ -2331,7 +2335,7 @@ pub fn subslice_offset(outer: &str, inner: &str) -> uint { * * s - A string * * n - The number of bytes to reserve space for */ -#[inline(always)] +#[inline] pub fn reserve(s: &mut ~str, n: uint) { unsafe { let v: *mut ~[u8] = cast::transmute(s); @@ -2359,7 +2363,7 @@ pub fn reserve(s: &mut ~str, n: uint) { * * s - A string * * n - The number of bytes to reserve space for */ -#[inline(always)] +#[inline] pub fn reserve_at_least(s: &mut ~str, n: uint) { reserve(s, uint::next_power_of_two(n + 1u) - 1u) } @@ -2576,7 +2580,7 @@ pub mod traits { use str::append; impl<'self> Add<&'self str,~str> for ~str { - #[inline(always)] + #[inline(force)] fn add(&self, rhs: & &'self str) -> ~str { append(copy *self, (*rhs)) } @@ -2717,7 +2721,7 @@ impl<'self> StrSlice<'self> for &'self str { #[inline] fn is_alphanumeric(&self) -> bool { is_alphanumeric(*self) } /// Returns the size in bytes not counting the null terminator - #[inline(always)] + #[inline(force)] fn len(&self) -> uint { len(*self) } /// Returns the number of characters that a string holds #[inline] @@ -2839,7 +2843,7 @@ impl OwnedStr for ~str { } impl Clone for ~str { - #[inline(always)] + #[inline(force)] fn clone(&self) -> ~str { to_owned(*self) } diff --git a/src/libstd/str/ascii.rs b/src/libstd/str/ascii.rs index 3b31d70f7a1bd..7f2ffa09eb18d 100644 --- a/src/libstd/str/ascii.rs +++ b/src/libstd/str/ascii.rs @@ -23,19 +23,19 @@ pub struct Ascii { priv chr: u8 } impl Ascii { /// Converts a ascii character into a `u8`. - #[inline(always)] + #[inline(force)] pub fn to_byte(self) -> u8 { self.chr } /// Converts a ascii character into a `char`. - #[inline(always)] + #[inline(force)] pub fn to_char(self) -> char { self.chr as char } /// Convert to lowercase. - #[inline(always)] + #[inline(force)] pub fn to_lower(self) -> Ascii { if self.chr >= 65 && self.chr <= 90 { Ascii{chr: self.chr | 0x20 } @@ -45,7 +45,7 @@ impl Ascii { } /// Convert to uppercase. - #[inline(always)] + #[inline(force)] pub fn to_upper(self) -> Ascii { if self.chr >= 97 && self.chr <= 122 { Ascii{chr: self.chr & !0x20 } @@ -55,14 +55,14 @@ impl Ascii { } /// Compares two ascii characters of equality, ignoring case. - #[inline(always)] + #[inline(force)] pub fn eq_ignore_case(self, other: Ascii) -> bool { self.to_lower().chr == other.to_lower().chr } } impl ToStr for Ascii { - #[inline(always)] + #[inline(force)] fn to_str(&self) -> ~str { str::from_bytes(['\'' as u8, self.chr, '\'' as u8]) } } @@ -76,13 +76,13 @@ pub trait AsciiCast { } impl<'self> AsciiCast<&'self[Ascii]> for &'self [u8] { - #[inline(always)] + #[inline(force)] fn to_ascii(&self) -> &'self[Ascii] { assert!(self.is_ascii()); unsafe{ cast::transmute(*self) } } - #[inline(always)] + #[inline(force)] fn is_ascii(&self) -> bool { for self.each |b| { if !b.is_ascii() { return false; } @@ -92,14 +92,14 @@ impl<'self> AsciiCast<&'self[Ascii]> for &'self [u8] { } impl<'self> AsciiCast<&'self[Ascii]> for &'self str { - #[inline(always)] + #[inline(force)] fn to_ascii(&self) -> &'self[Ascii] { assert!(self.is_ascii()); let (p,len): (*u8, uint) = unsafe{ cast::transmute(*self) }; unsafe{ cast::transmute((p, len - 1))} } - #[inline(always)] + #[inline(force)] fn is_ascii(&self) -> bool { for self.each |b| { if !b.is_ascii() { return false; } @@ -109,26 +109,26 @@ impl<'self> AsciiCast<&'self[Ascii]> for &'self str { } impl AsciiCast for u8 { - #[inline(always)] + #[inline(force)] fn to_ascii(&self) -> Ascii { assert!(self.is_ascii()); Ascii{ chr: *self } } - #[inline(always)] + #[inline(force)] fn is_ascii(&self) -> bool { *self & 128 == 0u8 } } impl AsciiCast for char { - #[inline(always)] + #[inline(force)] fn to_ascii(&self) -> Ascii { assert!(self.is_ascii()); Ascii{ chr: *self as u8 } } - #[inline(always)] + #[inline(force)] fn is_ascii(&self) -> bool { *self - ('\x7F' & *self) == '\x00' } @@ -141,7 +141,7 @@ pub trait OwnedAsciiCast { } impl OwnedAsciiCast for ~[u8] { - #[inline(always)] + #[inline(force)] fn to_ascii_consume(self) -> ~[Ascii] { assert!(self.is_ascii()); unsafe {cast::transmute(self)} @@ -149,7 +149,7 @@ impl OwnedAsciiCast for ~[u8] { } impl OwnedAsciiCast for ~str { - #[inline(always)] + #[inline(force)] fn to_ascii_consume(self) -> ~[Ascii] { assert!(self.is_ascii()); let mut s = self; @@ -174,26 +174,26 @@ pub trait AsciiStr { } impl<'self> AsciiStr for &'self [Ascii] { - #[inline(always)] + #[inline] fn to_str_ascii(&self) -> ~str { let mut cpy = self.to_owned(); cpy.push(0u8.to_ascii()); unsafe {cast::transmute(cpy)} } - #[inline(always)] + #[inline] fn to_lower(&self) -> ~[Ascii] { self.map(|a| a.to_lower()) } - #[inline(always)] + #[inline] fn to_upper(&self) -> ~[Ascii] { self.map(|a| a.to_upper()) } } impl ToStrConsume for ~[Ascii] { - #[inline(always)] + #[inline] fn to_str_consume(self) -> ~str { let mut cpy = self; cpy.push(0u8.to_ascii()); diff --git a/src/libstd/sys.rs b/src/libstd/sys.rs index 583923bc2e3aa..d535d30f428cb 100644 --- a/src/libstd/sys.rs +++ b/src/libstd/sys.rs @@ -58,25 +58,25 @@ pub mod rustrt { * Useful for calling certain function in the Rust runtime or otherwise * performing dark magick. */ -#[inline(always)] +#[inline(force)] pub fn get_type_desc() -> *TypeDesc { unsafe { intrinsics::get_tydesc::() as *TypeDesc } } /// Returns a pointer to a type descriptor. -#[inline(always)] +#[inline(force)] pub fn get_type_desc_val(_val: &T) -> *TypeDesc { get_type_desc::() } /// Returns the size of a type -#[inline(always)] +#[inline(force)] pub fn size_of() -> uint { unsafe { intrinsics::size_of::() } } /// Returns the size of the type that `_val` points to -#[inline(always)] +#[inline(force)] pub fn size_of_val(_val: &T) -> uint { size_of::() } @@ -86,14 +86,14 @@ pub fn size_of_val(_val: &T) -> uint { * * Useful for building structures containing variable-length arrays. */ -#[inline(always)] +#[inline(force)] pub fn nonzero_size_of() -> uint { let s = size_of::(); if s == 0 { 1 } else { s } } /// Returns the size of the type of the value that `_val` points to -#[inline(always)] +#[inline(force)] pub fn nonzero_size_of_val(_val: &T) -> uint { nonzero_size_of::() } @@ -105,33 +105,33 @@ pub fn nonzero_size_of_val(_val: &T) -> uint { * This is the alignment used for struct fields. It may be smaller * than the preferred alignment. */ -#[inline(always)] +#[inline(force)] pub fn min_align_of() -> uint { unsafe { intrinsics::min_align_of::() } } /// Returns the ABI-required minimum alignment of the type of the value that /// `_val` points to -#[inline(always)] +#[inline(force)] pub fn min_align_of_val(_val: &T) -> uint { min_align_of::() } /// Returns the preferred alignment of a type -#[inline(always)] +#[inline(force)] pub fn pref_align_of() -> uint { unsafe { intrinsics::pref_align_of::() } } /// Returns the preferred alignment of the type of the value that /// `_val` points to -#[inline(always)] +#[inline(force)] pub fn pref_align_of_val(_val: &T) -> uint { pref_align_of::() } /// Returns the refcount of a shared box (as just before calling this) -#[inline(always)] +#[inline(force)] pub fn refcount(t: @T) -> uint { unsafe { let ref_ptr: *uint = cast::transmute_copy(&t); diff --git a/src/libstd/task/spawn.rs b/src/libstd/task/spawn.rs index 87e9296657f48..7dbff170d5117 100644 --- a/src/libstd/task/spawn.rs +++ b/src/libstd/task/spawn.rs @@ -160,14 +160,14 @@ struct AncestorNode { struct AncestorList(Option>); // Accessors for taskgroup arcs and ancestor arcs that wrap the unsafety. -#[inline(always)] +#[inline(force)] fn access_group(x: &TaskGroupArc, blk: &fn(TaskGroupInner) -> U) -> U { unsafe { x.with(blk) } } -#[inline(always)] +#[inline(force)] fn access_ancestors(x: &Exclusive, blk: &fn(x: &mut AncestorNode) -> U) -> U { unsafe { diff --git a/src/libstd/to_bytes.rs b/src/libstd/to_bytes.rs index 77e7583ebe532..7a90138e76b7a 100644 --- a/src/libstd/to_bytes.rs +++ b/src/libstd/to_bytes.rs @@ -48,7 +48,7 @@ pub trait IterBytes { } impl IterBytes for bool { - #[inline(always)] + #[inline(force)] fn iter_bytes(&self, _lsb0: bool, f: Cb) -> bool { f([ *self as u8 @@ -57,7 +57,7 @@ impl IterBytes for bool { } impl IterBytes for u8 { - #[inline(always)] + #[inline(force)] fn iter_bytes(&self, _lsb0: bool, f: Cb) -> bool { f([ *self @@ -66,7 +66,7 @@ impl IterBytes for u8 { } impl IterBytes for u16 { - #[inline(always)] + #[inline(force)] fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool { if lsb0 { f([ @@ -83,7 +83,7 @@ impl IterBytes for u16 { } impl IterBytes for u32 { - #[inline(always)] + #[inline(force)] fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool { if lsb0 { f([ @@ -104,7 +104,7 @@ impl IterBytes for u32 { } impl IterBytes for u64 { - #[inline(always)] + #[inline(force)] fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool { if lsb0 { f([ @@ -133,35 +133,35 @@ impl IterBytes for u64 { } impl IterBytes for i8 { - #[inline(always)] + #[inline(force)] fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool { (*self as u8).iter_bytes(lsb0, f) } } impl IterBytes for i16 { - #[inline(always)] + #[inline(force)] fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool { (*self as u16).iter_bytes(lsb0, f) } } impl IterBytes for i32 { - #[inline(always)] + #[inline(force)] fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool { (*self as u32).iter_bytes(lsb0, f) } } impl IterBytes for i64 { - #[inline(always)] + #[inline(force)] fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool { (*self as u64).iter_bytes(lsb0, f) } } impl IterBytes for char { - #[inline(always)] + #[inline(force)] fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool { (*self as u32).iter_bytes(lsb0, f) } @@ -169,7 +169,7 @@ impl IterBytes for char { #[cfg(target_word_size = "32")] impl IterBytes for uint { - #[inline(always)] + #[inline(force)] fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool { (*self as u32).iter_bytes(lsb0, f) } @@ -177,28 +177,28 @@ impl IterBytes for uint { #[cfg(target_word_size = "64")] impl IterBytes for uint { - #[inline(always)] + #[inline(force)] fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool { (*self as u64).iter_bytes(lsb0, f) } } impl IterBytes for int { - #[inline(always)] + #[inline(force)] fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool { (*self as uint).iter_bytes(lsb0, f) } } impl<'self,A:IterBytes> IterBytes for &'self [A] { - #[inline(always)] + #[inline(force)] fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool { self.each(|elt| elt.iter_bytes(lsb0, |b| f(b))) } } impl IterBytes for (A,B) { - #[inline(always)] + #[inline(force)] fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool { match *self { (ref a, ref b) => { a.iter_bytes(lsb0, f) && b.iter_bytes(lsb0, f) } @@ -207,7 +207,7 @@ impl IterBytes for (A,B) { } impl IterBytes for (A,B,C) { - #[inline(always)] + #[inline(force)] fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool { match *self { (ref a, ref b, ref c) => { @@ -223,21 +223,21 @@ fn borrow<'x,A>(a: &'x [A]) -> &'x [A] { } impl IterBytes for ~[A] { - #[inline(always)] + #[inline(force)] fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool { borrow(*self).iter_bytes(lsb0, f) } } impl IterBytes for @[A] { - #[inline(always)] + #[inline(force)] fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool { borrow(*self).iter_bytes(lsb0, f) } } impl<'self> IterBytes for &'self str { - #[inline(always)] + #[inline(force)] fn iter_bytes(&self, _lsb0: bool, f: Cb) -> bool { do str::byte_slice(*self) |bytes| { f(bytes) @@ -246,7 +246,7 @@ impl<'self> IterBytes for &'self str { } impl IterBytes for ~str { - #[inline(always)] + #[inline(force)] fn iter_bytes(&self, _lsb0: bool, f: Cb) -> bool { do str::byte_slice(*self) |bytes| { f(bytes) @@ -255,7 +255,7 @@ impl IterBytes for ~str { } impl IterBytes for @str { - #[inline(always)] + #[inline(force)] fn iter_bytes(&self, _lsb0: bool, f: Cb) -> bool { do str::byte_slice(*self) |bytes| { f(bytes) @@ -264,7 +264,7 @@ impl IterBytes for @str { } impl IterBytes for Option { - #[inline(always)] + #[inline(force)] fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool { match *self { Some(ref a) => 0u8.iter_bytes(lsb0, f) && a.iter_bytes(lsb0, f), @@ -274,21 +274,21 @@ impl IterBytes for Option { } impl<'self,A:IterBytes> IterBytes for &'self A { - #[inline(always)] + #[inline(force)] fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool { (**self).iter_bytes(lsb0, f) } } impl IterBytes for @A { - #[inline(always)] + #[inline(force)] fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool { (**self).iter_bytes(lsb0, f) } } impl IterBytes for ~A { - #[inline(always)] + #[inline(force)] fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool { (**self).iter_bytes(lsb0, f) } @@ -297,7 +297,7 @@ impl IterBytes for ~A { // NB: raw-pointer IterBytes does _not_ dereference // to the target; it just gives you the pointer-bytes. impl IterBytes for *const A { - #[inline(always)] + #[inline(force)] fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool { (*self as uint).iter_bytes(lsb0, f) } diff --git a/src/libstd/to_str.rs b/src/libstd/to_str.rs index bfda92d46a284..0dad137a1b66b 100644 --- a/src/libstd/to_str.rs +++ b/src/libstd/to_str.rs @@ -35,12 +35,12 @@ pub trait ToStrConsume { } impl ToStr for () { - #[inline(always)] + #[inline] fn to_str(&self) -> ~str { ~"()" } } impl ToStr for (A,) { - #[inline(always)] + #[inline] fn to_str(&self) -> ~str { match *self { (ref a,) => { @@ -51,7 +51,7 @@ impl ToStr for (A,) { } impl ToStr for HashMap { - #[inline(always)] + #[inline] fn to_str(&self) -> ~str { let mut (acc, first) = (~"{", true); for self.each |key, value| { @@ -71,7 +71,7 @@ impl ToStr for HashMap { } impl ToStr for HashSet { - #[inline(always)] + #[inline] fn to_str(&self) -> ~str { let mut (acc, first) = (~"{", true); for self.each |element| { @@ -89,7 +89,7 @@ impl ToStr for HashSet { } impl ToStr for (A, B) { - #[inline(always)] + #[inline] fn to_str(&self) -> ~str { // FIXME(#4653): this causes an llvm assertion //let &(ref a, ref b) = self; @@ -102,7 +102,7 @@ impl ToStr for (A, B) { } impl ToStr for (A, B, C) { - #[inline(always)] + #[inline] fn to_str(&self) -> ~str { // FIXME(#4653): this causes an llvm assertion //let &(ref a, ref b, ref c) = self; @@ -119,7 +119,7 @@ impl ToStr for (A, B, C) { } impl<'self,A:ToStr> ToStr for &'self [A] { - #[inline(always)] + #[inline] fn to_str(&self) -> ~str { let mut (acc, first) = (~"[", true); for self.each |elt| { @@ -137,7 +137,7 @@ impl<'self,A:ToStr> ToStr for &'self [A] { } impl ToStr for ~[A] { - #[inline(always)] + #[inline] fn to_str(&self) -> ~str { let mut (acc, first) = (~"[", true); for self.each |elt| { @@ -155,7 +155,7 @@ impl ToStr for ~[A] { } impl ToStr for @[A] { - #[inline(always)] + #[inline] fn to_str(&self) -> ~str { let mut (acc, first) = (~"[", true); for self.each |elt| { diff --git a/src/libstd/trie.rs b/src/libstd/trie.rs index aea03b437ca13..f3bcc54256822 100644 --- a/src/libstd/trie.rs +++ b/src/libstd/trie.rs @@ -34,17 +34,17 @@ pub struct TrieMap { impl Container for TrieMap { /// Return the number of elements in the map - #[inline(always)] + #[inline] fn len(&const self) -> uint { self.length } /// Return true if the map contains no elements - #[inline(always)] + #[inline] fn is_empty(&const self) -> bool { self.len() == 0 } } impl Mutable for TrieMap { /// Clear the map, removing all values. - #[inline(always)] + #[inline] fn clear(&mut self) { self.root = TrieNode::new(); self.length = 0; @@ -53,37 +53,37 @@ impl Mutable for TrieMap { impl Map for TrieMap { /// Return true if the map contains a value for the specified key - #[inline(always)] + #[inline] fn contains_key(&self, key: &uint) -> bool { self.find(key).is_some() } /// Visit all key-value pairs in order - #[inline(always)] + #[inline(force)] fn each<'a>(&'a self, f: &fn(&uint, &'a T) -> bool) -> bool { self.root.each(f) } /// Visit all keys in order - #[inline(always)] + #[inline(force)] fn each_key(&self, f: &fn(&uint) -> bool) -> bool { self.each(|k, _| f(k)) } /// Visit all values in order - #[inline(always)] + #[inline(force)] fn each_value<'a>(&'a self, f: &fn(&'a T) -> bool) -> bool { self.each(|_, v| f(v)) } /// Iterate over the map and mutate the contained values - #[inline(always)] + #[inline(force)] fn mutate_values(&mut self, f: &fn(&uint, &mut T) -> bool) -> bool { self.root.mutate_values(f) } /// Return a reference to the value corresponding to the key - #[inline(hint)] + #[inline] fn find<'a>(&'a self, key: &uint) -> Option<&'a T> { let mut node: &'a TrieNode = &self.root; let mut idx = 0; @@ -104,7 +104,7 @@ impl Map for TrieMap { } /// Return a mutable reference to the value corresponding to the key - #[inline(always)] + #[inline] fn find_mut<'a>(&'a mut self, key: &uint) -> Option<&'a mut T> { find_mut(&mut self.root.children[chunk(*key, 0)], *key, 1) } @@ -112,14 +112,14 @@ impl Map for TrieMap { /// Insert a key-value pair into the map. An existing value for a /// key is replaced by the new value. Return true if the key did /// not already exist in the map. - #[inline(always)] + #[inline] fn insert(&mut self, key: uint, value: T) -> bool { self.swap(key, value).is_none() } /// Remove a key-value pair from the map. Return true if the key /// was present in the map, otherwise false. - #[inline(always)] + #[inline] fn remove(&mut self, key: &uint) -> bool { self.pop(key).is_some() } @@ -147,25 +147,25 @@ impl Map for TrieMap { impl TrieMap { /// Create an empty TrieMap - #[inline(always)] + #[inline] pub fn new() -> TrieMap { TrieMap{root: TrieNode::new(), length: 0} } /// Visit all key-value pairs in reverse order - #[inline(always)] + #[inline(force)] pub fn each_reverse<'a>(&'a self, f: &fn(&uint, &'a T) -> bool) -> bool { self.root.each_reverse(f) } /// Visit all keys in reverse order - #[inline(always)] + #[inline(force)] pub fn each_key_reverse(&self, f: &fn(&uint) -> bool) -> bool { self.each_reverse(|k, _| f(k)) } /// Visit all values in reverse order - #[inline(always)] + #[inline(force)] pub fn each_value_reverse(&self, f: &fn(&T) -> bool) -> bool { self.each_reverse(|_, v| f(v)) } @@ -178,15 +178,15 @@ pub struct TrieSet { impl BaseIter for TrieSet { /// Visit all values in order - #[inline(always)] + #[inline(force)] fn each(&self, f: &fn(&uint) -> bool) -> bool { self.map.each_key(f) } - #[inline(always)] + #[inline(force)] fn size_hint(&self) -> Option { Some(self.len()) } } impl ReverseIter for TrieSet { /// Visit all values in reverse order - #[inline(always)] + #[inline(force)] fn each_reverse(&self, f: &fn(&uint) -> bool) -> bool { self.map.each_key_reverse(f) } @@ -194,43 +194,43 @@ impl ReverseIter for TrieSet { impl Container for TrieSet { /// Return the number of elements in the set - #[inline(always)] + #[inline] fn len(&const self) -> uint { self.map.len() } /// Return true if the set contains no elements - #[inline(always)] + #[inline] fn is_empty(&const self) -> bool { self.map.is_empty() } } impl Mutable for TrieSet { /// Clear the set, removing all values. - #[inline(always)] + #[inline] fn clear(&mut self) { self.map.clear() } } impl TrieSet { /// Create an empty TrieSet - #[inline(always)] + #[inline] pub fn new() -> TrieSet { TrieSet{map: TrieMap::new()} } /// Return true if the set contains a value - #[inline(always)] + #[inline] pub fn contains(&self, value: &uint) -> bool { self.map.contains_key(value) } /// Add a value to the set. Return true if the value was not already /// present in the set. - #[inline(always)] + #[inline] pub fn insert(&mut self, value: uint) -> bool { self.map.insert(value, ()) } /// Remove a value from the set. Return true if the value was /// present in the set. - #[inline(always)] + #[inline] pub fn remove(&mut self, value: &uint) -> bool { self.map.remove(value) } @@ -242,7 +242,7 @@ struct TrieNode { } impl TrieNode { - #[inline(always)] + #[inline] fn new() -> TrieNode { // FIXME: #5244: [Nothing, ..SIZE] should be possible without Copy TrieNode{count: 0, @@ -291,7 +291,7 @@ impl TrieNode { } // if this was done via a trait, the key could be generic -#[inline(always)] +#[inline] fn chunk(n: uint, idx: uint) -> uint { let sh = uint::bits - (SHIFT * (idx + 1)); (n >> sh) & MASK diff --git a/src/libstd/tuple.rs b/src/libstd/tuple.rs index 589c18de0abf5..d93bc2c08a9ac 100644 --- a/src/libstd/tuple.rs +++ b/src/libstd/tuple.rs @@ -29,7 +29,7 @@ pub trait CopyableTuple { impl CopyableTuple for (T, U) { /// Return the first element of self - #[inline(always)] + #[inline] fn first(&self) -> T { match *self { (t, _) => t, @@ -37,7 +37,7 @@ impl CopyableTuple for (T, U) { } /// Return the second element of self - #[inline(always)] + #[inline] fn second(&self) -> U { match *self { (_, u) => u, @@ -45,7 +45,7 @@ impl CopyableTuple for (T, U) { } /// Return the results of swapping the two elements of self - #[inline(always)] + #[inline] fn swap(&self) -> (U, T) { match *self { (t, u) => (u, t), @@ -63,13 +63,13 @@ pub trait ImmutableTuple { } impl ImmutableTuple for (T, U) { - #[inline(always)] + #[inline] fn first_ref<'a>(&'a self) -> &'a T { match *self { (ref t, _) => t, } } - #[inline(always)] + #[inline] fn second_ref<'a>(&'a self) -> &'a U { match *self { (_, ref u) => u, @@ -83,7 +83,7 @@ pub trait ExtendedTupleOps { } impl<'self,A:Copy,B:Copy> ExtendedTupleOps for (&'self [A], &'self [B]) { - #[inline(always)] + #[inline] fn zip(&self) -> ~[(A, B)] { match *self { (ref a, ref b) => { @@ -92,7 +92,7 @@ impl<'self,A:Copy,B:Copy> ExtendedTupleOps for (&'self [A], &'self [B]) { } } - #[inline(always)] + #[inline(force)] fn map(&self, f: &fn(a: &A, b: &B) -> C) -> ~[C] { match *self { (ref a, ref b) => { @@ -103,7 +103,7 @@ impl<'self,A:Copy,B:Copy> ExtendedTupleOps for (&'self [A], &'self [B]) { } impl ExtendedTupleOps for (~[A], ~[B]) { - #[inline(always)] + #[inline] fn zip(&self) -> ~[(A, B)] { match *self { (ref a, ref b) => { @@ -112,7 +112,7 @@ impl ExtendedTupleOps for (~[A], ~[B]) { } } - #[inline(always)] + #[inline(force)] fn map(&self, f: &fn(a: &A, b: &B) -> C) -> ~[C] { match *self { (ref a, ref b) => { @@ -143,7 +143,7 @@ macro_rules! tuple_impls { impl<$($T:Clone),+> $cloneable_trait<$($T),+> for ($($T),+) { $( - #[inline(always)] + #[inline] fn $get_fn(&self) -> $T { self.$get_ref_fn().clone() } @@ -156,7 +156,7 @@ macro_rules! tuple_impls { impl<$($T),+> $immutable_trait<$($T),+> for ($($T),+) { $( - #[inline(always)] + #[inline] fn $get_ref_fn<'a>(&'a self) -> &'a $T { match *self { $get_pattern => $ret } } @@ -171,11 +171,11 @@ macro_rules! tuple_impls { #[cfg(not(test))] impl<$($T:Eq),+> Eq for ($($T),+) { - #[inline(always)] + #[inline(force)] fn eq(&self, other: &($($T),+)) -> bool { $(*self.$get_ref_fn() == *other.$get_ref_fn())&&+ } - #[inline(always)] + #[inline(force)] fn ne(&self, other: &($($T),+)) -> bool { !(*self == *other) } @@ -183,7 +183,7 @@ macro_rules! tuple_impls { #[cfg(not(test))] impl<$($T:TotalEq),+> TotalEq for ($($T),+) { - #[inline(always)] + #[inline(force)] fn equals(&self, other: &($($T),+)) -> bool { $(self.$get_ref_fn().equals(other.$get_ref_fn()))&&+ } @@ -191,15 +191,15 @@ macro_rules! tuple_impls { #[cfg(not(test))] impl<$($T:Ord),+> Ord for ($($T),+) { - #[inline(always)] + #[inline(force)] fn lt(&self, other: &($($T),+)) -> bool { lexical_lt!($(self.$get_ref_fn(), other.$get_ref_fn()),+) } - #[inline(always)] + #[inline(force)] fn le(&self, other: &($($T),+)) -> bool { !(*other).lt(&(*self)) } - #[inline(always)] + #[inline(force)] fn ge(&self, other: &($($T),+)) -> bool { !(*self).lt(other) } - #[inline(always)] + #[inline(force)] fn gt(&self, other: &($($T),+)) -> bool { (*other).lt(&(*self)) } } diff --git a/src/libstd/unstable/atomics.rs b/src/libstd/unstable/atomics.rs index 58d0c01f990d0..8b5abcd93b315 100644 --- a/src/libstd/unstable/atomics.rs +++ b/src/libstd/unstable/atomics.rs @@ -82,7 +82,7 @@ impl AtomicFlag { /** * Clears the atomic flag */ - #[inline(always)] + #[inline(force)] pub fn clear(&mut self, order: Ordering) { unsafe {atomic_store(&mut self.v, 0, order)} } @@ -91,7 +91,7 @@ impl AtomicFlag { * Sets the flag if it was previously unset, returns the previous value of the * flag. */ - #[inline(always)] + #[inline(force)] pub fn test_and_set(&mut self, order: Ordering) -> bool { unsafe {atomic_compare_and_swap(&mut self.v, 0, 1, order) > 0} } @@ -102,26 +102,26 @@ impl AtomicBool { AtomicBool { v: if v { 1 } else { 0 } } } - #[inline(always)] + #[inline(force)] pub fn load(&self, order: Ordering) -> bool { unsafe { atomic_load(&self.v, order) > 0 } } - #[inline(always)] + #[inline(force)] pub fn store(&mut self, val: bool, order: Ordering) { let val = if val { 1 } else { 0 }; unsafe { atomic_store(&mut self.v, val, order); } } - #[inline(always)] + #[inline(force)] pub fn swap(&mut self, val: bool, order: Ordering) -> bool { let val = if val { 1 } else { 0 }; unsafe { atomic_swap(&mut self.v, val, order) > 0} } - #[inline(always)] + #[inline(force)] pub fn compare_and_swap(&mut self, old: bool, new: bool, order: Ordering) -> bool { let old = if old { 1 } else { 0 }; let new = if new { 1 } else { 0 }; @@ -135,32 +135,32 @@ impl AtomicInt { AtomicInt { v:v } } - #[inline(always)] + #[inline(force)] pub fn load(&self, order: Ordering) -> int { unsafe { atomic_load(&self.v, order) } } - #[inline(always)] + #[inline(force)] pub fn store(&mut self, val: int, order: Ordering) { unsafe { atomic_store(&mut self.v, val, order); } } - #[inline(always)] + #[inline(force)] pub fn swap(&mut self, val: int, order: Ordering) -> int { unsafe { atomic_swap(&mut self.v, val, order) } } - #[inline(always)] + #[inline(force)] pub fn compare_and_swap(&mut self, old: int, new: int, order: Ordering) -> int { unsafe { atomic_compare_and_swap(&mut self.v, old, new, order) } } - #[inline(always)] + #[inline(force)] pub fn fetch_add(&mut self, val: int, order: Ordering) -> int { unsafe { atomic_add(&mut self.v, val, order) } } - #[inline(always)] + #[inline(force)] pub fn fetch_sub(&mut self, val: int, order: Ordering) -> int { unsafe { atomic_sub(&mut self.v, val, order) } } @@ -171,32 +171,32 @@ impl AtomicUint { AtomicUint { v:v } } - #[inline(always)] + #[inline(force)] pub fn load(&self, order: Ordering) -> uint { unsafe { atomic_load(&self.v, order) } } - #[inline(always)] + #[inline(force)] pub fn store(&mut self, val: uint, order: Ordering) { unsafe { atomic_store(&mut self.v, val, order); } } - #[inline(always)] + #[inline(force)] pub fn swap(&mut self, val: uint, order: Ordering) -> uint { unsafe { atomic_swap(&mut self.v, val, order) } } - #[inline(always)] + #[inline(force)] pub fn compare_and_swap(&mut self, old: uint, new: uint, order: Ordering) -> uint { unsafe { atomic_compare_and_swap(&mut self.v, old, new, order) } } - #[inline(always)] + #[inline(force)] pub fn fetch_add(&mut self, val: uint, order: Ordering) -> uint { unsafe { atomic_add(&mut self.v, val, order) } } - #[inline(always)] + #[inline(force)] pub fn fetch_sub(&mut self, val: uint, order: Ordering) -> uint { unsafe { atomic_sub(&mut self.v, val, order) } } @@ -207,22 +207,22 @@ impl AtomicPtr { AtomicPtr { p:p } } - #[inline(always)] + #[inline(force)] pub fn load(&self, order: Ordering) -> *mut T { unsafe { atomic_load(&self.p, order) } } - #[inline(always)] + #[inline(force)] pub fn store(&mut self, ptr: *mut T, order: Ordering) { unsafe { atomic_store(&mut self.p, ptr, order); } } - #[inline(always)] + #[inline(force)] pub fn swap(&mut self, ptr: *mut T, order: Ordering) -> *mut T { unsafe { atomic_swap(&mut self.p, ptr, order) } } - #[inline(always)] + #[inline(force)] pub fn compare_and_swap(&mut self, old: *mut T, new: *mut T, order: Ordering) -> *mut T { unsafe { atomic_compare_and_swap(&mut self.p, old, new, order) } } @@ -245,7 +245,7 @@ impl AtomicOption { } } - #[inline(always)] + #[inline(force)] pub fn swap(&mut self, val: ~T, order: Ordering) -> Option<~T> { unsafe { let val = cast::transmute(val); @@ -261,7 +261,7 @@ impl AtomicOption { } } - #[inline(always)] + #[inline(force)] pub fn take(&mut self, order: Ordering) -> Option<~T> { unsafe { self.swap(cast::transmute(0), order) @@ -281,7 +281,7 @@ impl Drop for AtomicOption { } } -#[inline(always)] +#[inline(force)] pub unsafe fn atomic_store(dst: &mut T, val: T, order:Ordering) { let dst = cast::transmute(dst); let val = cast::transmute(val); @@ -292,7 +292,7 @@ pub unsafe fn atomic_store(dst: &mut T, val: T, order:Ordering) { } } -#[inline(always)] +#[inline(force)] pub unsafe fn atomic_load(dst: &T, order:Ordering) -> T { let dst = cast::transmute(dst); @@ -302,7 +302,7 @@ pub unsafe fn atomic_load(dst: &T, order:Ordering) -> T { }) } -#[inline(always)] +#[inline(force)] pub unsafe fn atomic_swap(dst: &mut T, val: T, order: Ordering) -> T { let dst = cast::transmute(dst); let val = cast::transmute(val); @@ -314,7 +314,7 @@ pub unsafe fn atomic_swap(dst: &mut T, val: T, order: Ordering) -> T { }) } -#[inline(always)] +#[inline(force)] pub unsafe fn atomic_add(dst: &mut T, val: T, order: Ordering) -> T { let dst = cast::transmute(dst); let val = cast::transmute(val); @@ -326,7 +326,7 @@ pub unsafe fn atomic_add(dst: &mut T, val: T, order: Ordering) -> T { }) } -#[inline(always)] +#[inline(force)] pub unsafe fn atomic_sub(dst: &mut T, val: T, order: Ordering) -> T { let dst = cast::transmute(dst); let val = cast::transmute(val); @@ -338,7 +338,7 @@ pub unsafe fn atomic_sub(dst: &mut T, val: T, order: Ordering) -> T { }) } -#[inline(always)] +#[inline(force)] pub unsafe fn atomic_compare_and_swap(dst:&mut T, old:T, new:T, order: Ordering) -> T { let dst = cast::transmute(dst); let old = cast::transmute(old); diff --git a/src/libstd/unstable/extfmt.rs b/src/libstd/unstable/extfmt.rs index 07bcf6d953c3a..057a2b9e2454c 100644 --- a/src/libstd/unstable/extfmt.rs +++ b/src/libstd/unstable/extfmt.rs @@ -673,7 +673,7 @@ pub mod rt { } buf.push_str(s); } - #[inline(always)] + #[inline] pub fn have_flag(flags: u32, f: u32) -> bool { flags & f != 0 } diff --git a/src/libstd/unstable/lang.rs b/src/libstd/unstable/lang.rs index 350b18d454169..499557dc58cba 100644 --- a/src/libstd/unstable/lang.rs +++ b/src/libstd/unstable/lang.rs @@ -151,7 +151,7 @@ unsafe fn fail_borrowed(box: *mut BoxRepr, file: *c_char, line: size_t) { // FIXME #4942: Make these signatures agree with exchange_alloc's signatures #[lang="exchange_malloc"] -#[inline(always)] +#[inline(force)] pub unsafe fn exchange_malloc(td: *c_char, size: uintptr_t) -> *c_char { transmute(global_heap::malloc(transmute(td), transmute(size))) } @@ -231,7 +231,7 @@ impl DebugPrints for io::fd_t { // inside a landing pad may corrupt the state of the exception handler. If a // problem occurs, call exit instead. #[lang="exchange_free"] -#[inline(always)] +#[inline(force)] pub unsafe fn exchange_free(ptr: *c_char) { global_heap::free(transmute(ptr)) } @@ -270,7 +270,7 @@ pub unsafe fn local_free(ptr: *c_char) { } #[lang="borrow_as_imm"] -#[inline(always)] +#[inline(force)] pub unsafe fn borrow_as_imm(a: *u8, file: *c_char, line: size_t) -> uint { let a: *mut BoxRepr = transmute(a); let old_ref_count = (*a).header.ref_count; @@ -288,7 +288,7 @@ pub unsafe fn borrow_as_imm(a: *u8, file: *c_char, line: size_t) -> uint { } #[lang="borrow_as_mut"] -#[inline(always)] +#[inline(force)] pub unsafe fn borrow_as_mut(a: *u8, file: *c_char, line: size_t) -> uint { let a: *mut BoxRepr = transmute(a); let old_ref_count = (*a).header.ref_count; @@ -345,7 +345,7 @@ pub unsafe fn unrecord_borrow(a: *u8, old_ref_count: uint, } #[lang="return_to_mut"] -#[inline(always)] +#[inline(force)] pub unsafe fn return_to_mut(a: *u8, orig_ref_count: uint, file: *c_char, line: size_t) { // Sometimes the box is null, if it is conditionally frozen. @@ -364,7 +364,7 @@ pub unsafe fn return_to_mut(a: *u8, orig_ref_count: uint, } #[lang="check_not_borrowed"] -#[inline(always)] +#[inline(force)] pub unsafe fn check_not_borrowed(a: *u8, file: *c_char, line: size_t) { @@ -377,7 +377,7 @@ pub unsafe fn check_not_borrowed(a: *u8, } #[lang="strdup_uniq"] -#[inline(always)] +#[inline(force)] pub unsafe fn strdup_uniq(ptr: *c_uchar, len: uint) -> ~str { str::raw::from_buf_len(ptr, len) } diff --git a/src/libstd/unstable/sync.rs b/src/libstd/unstable/sync.rs index f0b178c667013..5e720ffe9f185 100644 --- a/src/libstd/unstable/sync.rs +++ b/src/libstd/unstable/sync.rs @@ -40,7 +40,7 @@ impl UnsafeAtomicRcBox { } } - #[inline(always)] + #[inline] pub unsafe fn get(&self) -> *mut T { let mut data: ~AtomicRcBoxData = cast::transmute(self.data); @@ -50,7 +50,7 @@ impl UnsafeAtomicRcBox { return r; } - #[inline(always)] + #[inline] pub unsafe fn get_immut(&self) -> *T { let mut data: ~AtomicRcBoxData = cast::transmute(self.data); @@ -118,7 +118,7 @@ fn LittleLock() -> LittleLock { } impl LittleLock { - #[inline(always)] + #[inline(force)] pub unsafe fn lock(&self, f: &fn() -> T) -> T { do atomically { rust_lock_little_lock(self.l); @@ -169,7 +169,7 @@ impl Exclusive { // Currently, scheduling operations (i.e., yielding, receiving on a pipe, // accessing the provided condition variable) are prohibited while inside // the exclusive. Supporting that is a work in progress. - #[inline(always)] + #[inline] pub unsafe fn with(&self, f: &fn(x: &mut T) -> U) -> U { let rec = self.x.get(); do (*rec).lock.lock { @@ -183,7 +183,7 @@ impl Exclusive { } } - #[inline(always)] + #[inline] pub unsafe fn with_imm(&self, f: &fn(x: &T) -> U) -> U { do self.with |x| { f(cast::transmute_immut(x)) diff --git a/src/libstd/util.rs b/src/libstd/util.rs index 376ead608bc06..01a0d114632f0 100644 --- a/src/libstd/util.rs +++ b/src/libstd/util.rs @@ -16,11 +16,11 @@ use prelude::*; use unstable::intrinsics; /// The identity function. -#[inline(always)] +#[inline(force)] pub fn id(x: T) -> T { x } /// Ignores a value. -#[inline(always)] +#[inline(force)] pub fn ignore(_x: T) { } /// Sets `*ptr` to `new_value`, invokes `op()`, and then restores the @@ -30,7 +30,7 @@ pub fn ignore(_x: T) { } /// an obvious borrowck hazard. Typically passing in `&mut T` will /// cause borrow check errors because it freezes whatever location /// that `&mut T` is stored in (either statically or dynamically). -#[inline(always)] +#[inline(force)] pub fn with( ptr: @mut T, value: T, @@ -46,7 +46,7 @@ pub fn with( * Swap the values at two mutable locations of the same type, without * deinitialising or copying either one. */ -#[inline(always)] +#[inline(force)] pub fn swap(x: &mut T, y: &mut T) { unsafe { // Give ourselves some scratch space to work with @@ -68,7 +68,7 @@ pub fn swap(x: &mut T, y: &mut T) { * Replace the value at a mutable location with a new one, returning the old * value, without deinitialising or copying either one. */ -#[inline(always)] +#[inline(force)] pub fn replace(dest: &mut T, mut src: T) -> T { swap(dest, &mut src); src diff --git a/src/libstd/vec.rs b/src/libstd/vec.rs index 8340b956b658f..15b3097666c42 100644 --- a/src/libstd/vec.rs +++ b/src/libstd/vec.rs @@ -115,7 +115,7 @@ pub fn reserve_at_least(v: &mut ~[T], n: uint) { } /// Returns the number of elements the vector can hold without reallocating -#[inline(always)] +#[inline] pub fn capacity(v: &const ~[T]) -> uint { unsafe { let repr: **raw::VecRepr = transmute(v); @@ -124,7 +124,7 @@ pub fn capacity(v: &const ~[T]) -> uint { } /// Returns the length of a vector -#[inline(always)] +#[inline] pub fn len(v: &const [T]) -> uint { as_const_buf(v, |_p, len| len) } @@ -206,7 +206,7 @@ pub fn with_capacity(capacity: uint) -> ~[T] { * as an argument a function that will push an element * onto the vector being constructed. */ -#[inline(always)] +#[inline(force)] pub fn build_sized(size: uint, builder: &fn(push: &fn(v: A))) -> ~[A] { let mut vec = with_capacity(size); builder(|x| vec.push(x)); @@ -223,7 +223,7 @@ pub fn build_sized(size: uint, builder: &fn(push: &fn(v: A))) -> ~[A] { * as an argument a function that will push an element * onto the vector being constructed. */ -#[inline(always)] +#[inline(force)] pub fn build(builder: &fn(push: &fn(v: A))) -> ~[A] { build_sized(4, builder) } @@ -240,7 +240,7 @@ pub fn build(builder: &fn(push: &fn(v: A))) -> ~[A] { * as an argument a function that will push an element * onto the vector being constructed. */ -#[inline(always)] +#[inline(force)] pub fn build_sized_opt(size: Option, builder: &fn(push: &fn(v: A))) -> ~[A] { @@ -288,7 +288,7 @@ pub fn last_opt<'r,T>(v: &'r [T]) -> Option<&'r T> { } /// Return a slice that points into another slice. -#[inline(always)] +#[inline] pub fn slice<'r,T>(v: &'r [T], start: uint, end: uint) -> &'r [T] { assert!(start <= end); assert!(end <= len(v)); @@ -301,7 +301,7 @@ pub fn slice<'r,T>(v: &'r [T], start: uint, end: uint) -> &'r [T] { } /// Return a slice that points into another slice. -#[inline(always)] +#[inline] pub fn mut_slice<'r,T>(v: &'r mut [T], start: uint, end: uint) -> &'r mut [T] { assert!(start <= end); @@ -315,7 +315,7 @@ pub fn mut_slice<'r,T>(v: &'r mut [T], start: uint, end: uint) } /// Return a slice that points into another slice. -#[inline(always)] +#[inline] pub fn const_slice<'r,T>(v: &'r const [T], start: uint, end: uint) -> &'r const [T] { assert!(start <= end); @@ -650,7 +650,7 @@ pub fn swap_remove(v: &mut ~[T], index: uint) -> T { } /// Append an element to a vector -#[inline(always)] +#[inline] pub fn push(v: &mut ~[T], initval: T) { unsafe { let repr: **raw::VecRepr = transmute(&mut *v); @@ -665,7 +665,7 @@ pub fn push(v: &mut ~[T], initval: T) { } // This doesn't bother to make sure we have space. -#[inline(always)] // really pretty please +#[inline(force)] // really pretty please unsafe fn push_fast(v: &mut ~[T], initval: T) { let repr: **mut raw::VecRepr = transmute(v); let fill = (**repr).unboxed.fill; @@ -692,7 +692,7 @@ fn push_slow(v: &mut ~[T], initval: T) { /// vec::push_all(&mut a, [2, 3, 4]); /// assert!(a == ~[1, 2, 3, 4]); /// ~~~ -#[inline(always)] +#[inline] pub fn push_all(v: &mut ~[T], rhs: &const [T]) { let new_len = v.len() + rhs.len(); reserve(&mut *v, new_len); @@ -713,7 +713,7 @@ pub fn push_all(v: &mut ~[T], rhs: &const [T]) { /// vec::push_all_move(&mut a, ~[~2, ~3, ~4]); /// assert!(a == ~[~1, ~2, ~3, ~4]); /// ~~~ -#[inline(always)] +#[inline] pub fn push_all_move(v: &mut ~[T], mut rhs: ~[T]) { let new_len = v.len() + rhs.len(); reserve(&mut *v, new_len); @@ -784,7 +784,7 @@ pub fn dedup(v: &mut ~[T]) { /// Iterates over the `rhs` vector, copying each element and appending it to the /// `lhs`. Afterwards, the `lhs` is then returned for use again. -#[inline(always)] +#[inline] pub fn append(lhs: ~[T], rhs: &const [T]) -> ~[T] { let mut v = lhs; v.push_all(rhs); @@ -793,7 +793,7 @@ pub fn append(lhs: ~[T], rhs: &const [T]) -> ~[T] { /// Appends one element to the vector provided. The vector itself is then /// returned for use again. -#[inline(always)] +#[inline] pub fn append_one(lhs: ~[T], x: T) -> ~[T] { let mut v = lhs; v.push(x); @@ -833,6 +833,7 @@ pub fn grow(v: &mut ~[T], n: uint, initval: &T) { * * init_op - A function to call to retreive each appended element's * value */ +#[inline(force)] pub fn grow_fn(v: &mut ~[T], n: uint, op: old_iter::InitOp) { let new_len = v.len() + n; reserve_at_least(&mut *v, new_len); @@ -860,6 +861,7 @@ pub fn grow_set(v: &mut ~[T], index: uint, initval: &T, val: T) { // Functional utilities /// Apply a function to each element of a vector and return the results +#[inline(force)] pub fn map(v: &[T], f: &fn(t: &T) -> U) -> ~[U] { let mut result = with_capacity(len(v)); for each(v) |elem| { @@ -875,6 +877,7 @@ pub fn map(v: &[T], f: &fn(t: &T) -> U) -> ~[U] { /// /// The original vector `v` cannot be used after this function call (it is moved /// inside), but there are no restrictions on the type of the vector. +#[inline(force)] pub fn map_consume(v: ~[T], f: &fn(v: T) -> U) -> ~[U] { let mut result = ~[]; do consume(v) |_i, x| { @@ -884,6 +887,7 @@ pub fn map_consume(v: ~[T], f: &fn(v: T) -> U) -> ~[U] { } /// Apply a function to each element of a vector and return the results +#[inline(force)] pub fn mapi(v: &[T], f: &fn(uint, t: &T) -> U) -> ~[U] { let mut i = 0; do map(v) |e| { @@ -896,6 +900,7 @@ pub fn mapi(v: &[T], f: &fn(uint, t: &T) -> U) -> ~[U] { * Apply a function to each element of a vector and return a concatenation * of each result vector */ +#[inline(force)] pub fn flat_map(v: &[T], f: &fn(t: &T) -> ~[U]) -> ~[U] { let mut result = ~[]; for each(v) |elem| { result.push_all_move(f(elem)); } @@ -906,6 +911,7 @@ pub fn flat_map(v: &[T], f: &fn(t: &T) -> ~[U]) -> ~[U] { * Apply a function to each pair of elements and return the results. * Equivalent to `map(zip(v0, v1), f)`. */ +#[inline(force)] pub fn map_zip(v0: &[T], v1: &[U], f: &fn(t: &T, v: &U) -> V) -> ~[V] { let v0_len = len(v0); @@ -919,6 +925,7 @@ pub fn map_zip(v0: &[T], v1: &[U], u } +#[inline(force)] pub fn filter_map( v: ~[T], f: &fn(t: T) -> Option) -> ~[U] @@ -940,6 +947,7 @@ pub fn filter_map( result } +#[inline(force)] pub fn filter_mapped( v: &[T], f: &fn(t: &T) -> Option) -> ~[U] @@ -967,6 +975,7 @@ pub fn filter_mapped( * Apply function `f` to each element of `v` and return a vector containing * only those elements for which `f` returned true. */ +#[inline(force)] pub fn filter(v: ~[T], f: &fn(t: &T) -> bool) -> ~[T] { let mut result = ~[]; // FIXME (#4355 maybe): using v.consume here crashes @@ -984,6 +993,7 @@ pub fn filter(v: ~[T], f: &fn(t: &T) -> bool) -> ~[T] { * Apply function `f` to each element of `v` and return a vector containing * only those elements for which `f` returned true. */ +#[inline(force)] pub fn filtered(v: &[T], f: &fn(t: &T) -> bool) -> ~[T] { let mut result = ~[]; for each(v) |elem| { @@ -995,6 +1005,7 @@ pub fn filtered(v: &[T], f: &fn(t: &T) -> bool) -> ~[T] { /** * Like `filter()`, but in place. Preserves order of `v`. Linear time. */ +#[inline(force)] pub fn retain(v: &mut ~[T], f: &fn(t: &T) -> bool) { let len = v.len(); let mut deleted: uint = 0; @@ -1013,15 +1024,19 @@ pub fn retain(v: &mut ~[T], f: &fn(t: &T) -> bool) { } /// Flattens a vector of vectors of T into a single vector of T. +#[inline] pub fn concat(v: &[~[T]]) -> ~[T] { v.concat() } /// Concatenate a vector of vectors, placing a given separator between each +#[inline] pub fn connect(v: &[~[T]], sep: &T) -> ~[T] { v.connect(sep) } /// Flattens a vector of vectors of T into a single vector of T. +#[inline] pub fn concat_slices(v: &[&[T]]) -> ~[T] { v.concat() } /// Concatenate a vector of vectors, placing a given separator between each +#[inline] pub fn connect_slices(v: &[&[T]], sep: &T) -> ~[T] { v.connect(sep) } #[allow(missing_doc)] @@ -1032,11 +1047,13 @@ pub trait VectorVector { impl<'self, T:Copy> VectorVector for &'self [~[T]] { /// Flattens a vector of slices of T into a single vector of T. + #[inline] pub fn concat(&self) -> ~[T] { self.flat_map(|&inner| inner) } /// Concatenate a vector of vectors, placing a given separator between each. + #[inline] pub fn connect(&self, sep: &T) -> ~[T] { let mut r = ~[]; let mut first = true; @@ -1050,11 +1067,13 @@ impl<'self, T:Copy> VectorVector for &'self [~[T]] { impl<'self, T:Copy> VectorVector for &'self [&'self [T]] { /// Flattens a vector of slices of T into a single vector of T. + #[inline] pub fn concat(&self) -> ~[T] { self.flat_map(|&inner| inner.to_owned()) } /// Concatenate a vector of slices, placing a given separator between each. + #[inline] pub fn connect(&self, sep: &T) -> ~[T] { let mut r = ~[]; let mut first = true; @@ -1083,6 +1102,7 @@ impl<'self, T:Copy> VectorVector for &'self [&'self [T]] { * ~~~ * */ +#[inline(force)] pub fn foldl<'a, T, U>(z: T, v: &'a [U], p: &fn(t: T, u: &'a U) -> T) -> T { let mut accum = z; let mut i = 0; @@ -1115,6 +1135,7 @@ pub fn foldl<'a, T, U>(z: T, v: &'a [U], p: &fn(t: T, u: &'a U) -> T) -> T { * ~~~ * */ +#[inline(force)] pub fn foldr<'a, T, U>(v: &'a [T], mut z: U, p: &fn(t: &'a T, u: U) -> U) -> U { let mut i = v.len(); while i > 0 { @@ -1436,7 +1457,7 @@ pub fn zip(mut v: ~[T], mut u: ~[U]) -> ~[(T, U)] { * * a - The index of the first element * * b - The index of the second element */ -#[inline(always)] +#[inline(force)] pub fn swap(v: &mut [T], a: uint, b: uint) { unsafe { // Can't take two mutable loans from one vector, so instead just cast @@ -1544,7 +1565,7 @@ pub fn reversed(v: &const [T]) -> ~[T] { * } * ~~~ */ -#[inline(always)] +#[inline(force)] pub fn each<'r,T>(v: &'r [T], f: &fn(&'r T) -> bool) -> bool { // ^^^^ // NB---this CANNOT be &const [T]! The reason @@ -1571,7 +1592,7 @@ pub fn each<'r,T>(v: &'r [T], f: &fn(&'r T) -> bool) -> bool { /// Like `each()`, but for the case where you have /// a vector with mutable contents and you would like /// to mutate the contents as you iterate. -#[inline(always)] +#[inline(force)] pub fn each_mut<'r,T>(v: &'r mut [T], f: &fn(elem: &'r mut T) -> bool) -> bool { let mut broke = false; do as_mut_buf(v) |p, n| { @@ -1592,7 +1613,7 @@ pub fn each_mut<'r,T>(v: &'r mut [T], f: &fn(elem: &'r mut T) -> bool) -> bool { /// Like `each()`, but for the case where you have a vector that *may or may /// not* have mutable contents. -#[inline(always)] +#[inline(force)] pub fn each_const(v: &const [T], f: &fn(elem: &const T) -> bool) -> bool { let mut i = 0; let n = v.len(); @@ -1610,7 +1631,7 @@ pub fn each_const(v: &const [T], f: &fn(elem: &const T) -> bool) -> bool { * * Return true to continue, false to break. */ -#[inline(always)] +#[inline(force)] pub fn eachi<'r,T>(v: &'r [T], f: &fn(uint, v: &'r T) -> bool) -> bool { let mut i = 0; for each(v) |p| { @@ -1625,7 +1646,7 @@ pub fn eachi<'r,T>(v: &'r [T], f: &fn(uint, v: &'r T) -> bool) -> bool { * * Return true to continue, false to break. */ -#[inline(always)] +#[inline(force)] pub fn eachi_mut<'r,T>(v: &'r mut [T], f: &fn(uint, v: &'r mut T) -> bool) -> bool { let mut i = 0; @@ -1643,7 +1664,7 @@ pub fn eachi_mut<'r,T>(v: &'r mut [T], * * Return true to continue, false to break. */ -#[inline(always)] +#[inline(force)] pub fn each_reverse<'r,T>(v: &'r [T], blk: &fn(v: &'r T) -> bool) -> bool { eachi_reverse(v, |_i, v| blk(v)) } @@ -1653,7 +1674,7 @@ pub fn each_reverse<'r,T>(v: &'r [T], blk: &fn(v: &'r T) -> bool) -> bool { * * Return true to continue, false to break. */ -#[inline(always)] +#[inline(force)] pub fn eachi_reverse<'r,T>(v: &'r [T], blk: &fn(i: uint, v: &'r T) -> bool) -> bool { let mut i = v.len(); @@ -1787,7 +1808,7 @@ pub fn windowed<'r, T>(n: uint, v: &'r [T], it: &fn(&'r [T]) -> bool) -> bool { * Allows for unsafe manipulation of vector contents, which is useful for * foreign interop. */ -#[inline(always)] +#[inline(force)] pub fn as_imm_buf(s: &[T], /* NB---this CANNOT be const, see below */ f: &fn(*T, uint) -> U) -> U { @@ -1806,7 +1827,7 @@ pub fn as_imm_buf(s: &[T], } /// Similar to `as_imm_buf` but passing a `*const T` -#[inline(always)] +#[inline(force)] pub fn as_const_buf(s: &const [T], f: &fn(*const T, uint) -> U) -> U { unsafe { let v : *(*const T,uint) = transmute(&s); @@ -1816,7 +1837,7 @@ pub fn as_const_buf(s: &const [T], f: &fn(*const T, uint) -> U) -> U { } /// Similar to `as_imm_buf` but passing a `*mut T` -#[inline(always)] +#[inline(force)] pub fn as_mut_buf(s: &mut [T], f: &fn(*mut T, uint) -> U) -> U { unsafe { let v : *(*mut T,uint) = transmute(&s); @@ -1830,6 +1851,7 @@ pub fn as_mut_buf(s: &mut [T], f: &fn(*mut T, uint) -> U) -> U { /// Tests whether two slices are equal to one another. This is only true if both /// slices are of the same length, and each of the corresponding elements return /// true when queried via the `eq` function. +#[inline] fn eq(a: &[T], b: &[T]) -> bool { let (a_len, b_len) = (a.len(), b.len()); if a_len != b_len { return false; } @@ -1845,6 +1867,7 @@ fn eq(a: &[T], b: &[T]) -> bool { /// Similar to the `vec::eq` function, but this is defined for types which /// implement `TotalEq` as opposed to types which implement `Eq`. Equality /// comparisons are done via the `equals` function instead of `eq`. +#[inline] fn equals(a: &[T], b: &[T]) -> bool { let (a_len, b_len) = (a.len(), b.len()); if a_len != b_len { return false; } @@ -1859,49 +1882,49 @@ fn equals(a: &[T], b: &[T]) -> bool { #[cfg(not(test))] impl<'self,T:Eq> Eq for &'self [T] { - #[inline(always)] + #[inline(force)] fn eq(&self, other: & &'self [T]) -> bool { eq(*self, *other) } - #[inline(always)] + #[inline(force)] fn ne(&self, other: & &'self [T]) -> bool { !self.eq(other) } } #[cfg(not(test))] impl Eq for ~[T] { - #[inline(always)] + #[inline(force)] fn eq(&self, other: &~[T]) -> bool { eq(*self, *other) } - #[inline(always)] + #[inline(force)] fn ne(&self, other: &~[T]) -> bool { !self.eq(other) } } #[cfg(not(test))] impl Eq for @[T] { - #[inline(always)] + #[inline(force)] fn eq(&self, other: &@[T]) -> bool { eq(*self, *other) } - #[inline(always)] + #[inline(force)] fn ne(&self, other: &@[T]) -> bool { !self.eq(other) } } #[cfg(not(test))] impl<'self,T:TotalEq> TotalEq for &'self [T] { - #[inline(always)] + #[inline(force)] fn equals(&self, other: & &'self [T]) -> bool { equals(*self, *other) } } #[cfg(not(test))] impl TotalEq for ~[T] { - #[inline(always)] + #[inline(force)] fn equals(&self, other: &~[T]) -> bool { equals(*self, *other) } } #[cfg(not(test))] impl TotalEq for @[T] { - #[inline(always)] + #[inline(force)] fn equals(&self, other: &@[T]) -> bool { equals(*self, *other) } } #[cfg(not(test))] impl<'self,T:Eq> Equiv<~[T]> for &'self [T] { - #[inline(always)] + #[inline(force)] fn equiv(&self, other: &~[T]) -> bool { eq(*self, *other) } } @@ -1923,19 +1946,19 @@ fn cmp(a: &[T], b: &[T]) -> Ordering { #[cfg(not(test))] impl<'self,T:TotalOrd> TotalOrd for &'self [T] { - #[inline(always)] + #[inline(force)] fn cmp(&self, other: & &'self [T]) -> Ordering { cmp(*self, *other) } } #[cfg(not(test))] impl TotalOrd for ~[T] { - #[inline(always)] + #[inline(force)] fn cmp(&self, other: &~[T]) -> Ordering { cmp(*self, *other) } } #[cfg(not(test))] impl TotalOrd for @[T] { - #[inline(always)] + #[inline(force)] fn cmp(&self, other: &@[T]) -> Ordering { cmp(*self, *other) } } @@ -1960,37 +1983,37 @@ fn gt(a: &[T], b: &[T]) -> bool { lt(b, a) } #[cfg(not(test))] impl<'self,T:Ord> Ord for &'self [T] { - #[inline(always)] + #[inline(force)] fn lt(&self, other: & &'self [T]) -> bool { lt((*self), (*other)) } - #[inline(always)] + #[inline(force)] fn le(&self, other: & &'self [T]) -> bool { le((*self), (*other)) } - #[inline(always)] + #[inline(force)] fn ge(&self, other: & &'self [T]) -> bool { ge((*self), (*other)) } - #[inline(always)] + #[inline(force)] fn gt(&self, other: & &'self [T]) -> bool { gt((*self), (*other)) } } #[cfg(not(test))] impl Ord for ~[T] { - #[inline(always)] + #[inline(force)] fn lt(&self, other: &~[T]) -> bool { lt((*self), (*other)) } - #[inline(always)] + #[inline(force)] fn le(&self, other: &~[T]) -> bool { le((*self), (*other)) } - #[inline(always)] + #[inline(force)] fn ge(&self, other: &~[T]) -> bool { ge((*self), (*other)) } - #[inline(always)] + #[inline(force)] fn gt(&self, other: &~[T]) -> bool { gt((*self), (*other)) } } #[cfg(not(test))] impl Ord for @[T] { - #[inline(always)] + #[inline(force)] fn lt(&self, other: &@[T]) -> bool { lt((*self), (*other)) } - #[inline(always)] + #[inline(force)] fn le(&self, other: &@[T]) -> bool { le((*self), (*other)) } - #[inline(always)] + #[inline(force)] fn ge(&self, other: &@[T]) -> bool { ge((*self), (*other)) } - #[inline(always)] + #[inline(force)] fn gt(&self, other: &@[T]) -> bool { gt((*self), (*other)) } } @@ -2001,7 +2024,7 @@ pub mod traits { use vec::append; impl<'self,T:Copy> Add<&'self const [T],~[T]> for ~[T] { - #[inline(always)] + #[inline(force)] fn add(&self, rhs: & &'self const [T]) -> ~[T] { append(copy *self, (*rhs)) } @@ -2150,24 +2173,25 @@ impl<'self,T> ImmutableVector<'self, T> for &'self [T] { } /// Reduce a vector from right to left - #[inline] + #[inline(force)] fn foldr<'a, U>(&'a self, z: U, p: &fn(t: &'a T, u: U) -> U) -> U { foldr(*self, z, p) } /// Apply a function to each element of a vector and return the results - #[inline] + #[inline(force)] fn map(&self, f: &fn(t: &T) -> U) -> ~[U] { map(*self, f) } /** * Apply a function to the index and value of each element in the vector * and return the results */ + #[inline(force)] fn mapi(&self, f: &fn(uint, t: &T) -> U) -> ~[U] { mapi(*self, f) } - #[inline] + #[inline(force)] fn map_r(&self, f: &fn(x: &T) -> U) -> ~[U] { let mut r = ~[]; let mut i = 0; @@ -2183,6 +2207,7 @@ impl<'self,T> ImmutableVector<'self, T> for &'self [T] { * * If the vector is empty, true is returned. */ + #[inline(force)] fn alli(&self, f: &fn(uint, t: &T) -> bool) -> bool { alli(*self, f) } @@ -2207,7 +2232,7 @@ impl<'self,T> ImmutableVector<'self, T> for &'self [T] { /// Returns a pointer to the element at the given index, without doing /// bounds checking. - #[inline(always)] + #[inline(force)] unsafe fn unsafe_ref(&self, index: uint) -> *T { let (ptr, _): (*T, uint) = transmute(*self); ptr.offset(index) @@ -2278,7 +2303,7 @@ impl<'self,T:Copy> ImmutableCopyableVector for &'self [T] { } /// Returns the element at the given index, without doing bounds checking. - #[inline(always)] + #[inline] unsafe fn unsafe_get(&self, index: uint) -> T { *self.unsafe_ref(index) } @@ -2449,14 +2474,14 @@ impl<'self,T> MutableVector<'self, T> for &'self mut [T] { } } - #[inline(always)] + #[inline(force)] unsafe fn unsafe_mut_ref(&self, index: uint) -> *mut T { let pair_ptr: &(*mut T, uint) = transmute(self); let (ptr, _) = *pair_ptr; ptr.offset(index) } - #[inline(always)] + #[inline(force)] unsafe fn unsafe_set(&self, index: uint, val: T) { *self.unsafe_mut_ref(index) = val; } @@ -2517,7 +2542,7 @@ pub mod raw { * modifing its buffers, so it is up to the caller to ensure that * the vector is actually the specified size. */ - #[inline(always)] + #[inline(force)] pub unsafe fn set_len(v: &mut ~[T], new_len: uint) { let repr: **mut VecRepr = transmute(v); (**repr).unboxed.fill = new_len * sys::nonzero_size_of::(); @@ -2532,7 +2557,7 @@ pub mod raw { * Modifying the vector may cause its buffer to be reallocated, which * would also make any pointers to it invalid. */ - #[inline(always)] + #[inline(force)] pub fn to_ptr(v: &[T]) -> *T { unsafe { let repr: **SliceRepr = transmute(&v); @@ -2541,7 +2566,7 @@ pub mod raw { } /** see `to_ptr()` */ - #[inline(always)] + #[inline(force)] pub fn to_const_ptr(v: &const [T]) -> *const T { unsafe { let repr: **SliceRepr = transmute(&v); @@ -2550,7 +2575,7 @@ pub mod raw { } /** see `to_ptr()` */ - #[inline(always)] + #[inline(force)] pub fn to_mut_ptr(v: &mut [T]) -> *mut T { unsafe { let repr: **SliceRepr = transmute(&v); @@ -2562,7 +2587,7 @@ pub mod raw { * Form a slice from a pointer and length (as a number of units, * not bytes). */ - #[inline(always)] + #[inline(force)] pub unsafe fn buf_as_slice(p: *T, len: uint, f: &fn(v: &[T]) -> U) -> U { @@ -2575,7 +2600,7 @@ pub mod raw { * Form a slice from a pointer and length (as a number of units, * not bytes). */ - #[inline(always)] + #[inline(force)] pub unsafe fn mut_buf_as_slice(p: *mut T, len: uint, f: &fn(v: &mut [T]) -> U) -> U { @@ -2587,7 +2612,7 @@ pub mod raw { /** * Unchecked vector indexing. */ - #[inline(always)] + #[inline(force)] pub unsafe fn get(v: &const [T], i: uint) -> T { as_const_buf(v, |p, _len| *ptr::const_offset(p, i)) } @@ -2597,7 +2622,7 @@ pub mod raw { * old value and hence is only suitable when the vector * is newly allocated. */ - #[inline(always)] + #[inline(force)] pub unsafe fn init_elem(v: &mut [T], i: uint, val: T) { let mut box = Some(val); do as_mut_buf(v) |p, _len| { @@ -2616,7 +2641,7 @@ pub mod raw { * * elts - The number of elements in the buffer */ // Was in raw, but needs to be called by net_tcp::on_tcp_read_cb - #[inline(always)] + #[inline(force)] pub unsafe fn from_buf_raw(ptr: *T, elts: uint) -> ~[T] { let mut dst = with_capacity(elts); set_len(&mut dst, elts); @@ -2630,7 +2655,7 @@ pub mod raw { * Copies `count` bytes from `src` to `dst`. The source and destination * may overlap. */ - #[inline(always)] + #[inline(force)] pub unsafe fn copy_memory(dst: &mut [T], src: &const [T], count: uint) { assert!(dst.len() >= count); @@ -2673,21 +2698,27 @@ pub mod bytes { } /// Bytewise less than or equal + #[inline] pub fn lt(a: &~[u8], b: &~[u8]) -> bool { memcmp(a, b) < 0 } /// Bytewise less than or equal + #[inline] pub fn le(a: &~[u8], b: &~[u8]) -> bool { memcmp(a, b) <= 0 } /// Bytewise equality + #[inline] pub fn eq(a: &~[u8], b: &~[u8]) -> bool { memcmp(a, b) == 0 } /// Bytewise inequality + #[inline] pub fn ne(a: &~[u8], b: &~[u8]) -> bool { memcmp(a, b) != 0 } /// Bytewise greater than or equal + #[inline] pub fn ge(a: &~[u8], b: &~[u8]) -> bool { memcmp(a, b) >= 0 } /// Bytewise greater than + #[inline] pub fn gt(a: &~[u8], b: &~[u8]) -> bool { memcmp(a, b) > 0 } /** @@ -2696,7 +2727,7 @@ pub mod bytes { * Copies `count` bytes from `src` to `dst`. The source and destination * may overlap. */ - #[inline(always)] + #[inline(force)] pub fn copy_memory(dst: &mut [u8], src: &const [u8], count: uint) { // Bound checks are done at vec::raw::copy_memory. unsafe { vec::raw::copy_memory(dst, src, count) } @@ -2707,36 +2738,36 @@ pub mod bytes { // ITERATION TRAIT METHODS impl<'self,A> old_iter::BaseIter for &'self [A] { - #[inline(always)] + #[inline(force)] fn each<'a>(&'a self, blk: &fn(v: &'a A) -> bool) -> bool { each(*self, blk) } - #[inline(always)] + #[inline] fn size_hint(&self) -> Option { Some(self.len()) } } // FIXME(#4148): This should be redundant impl old_iter::BaseIter for ~[A] { - #[inline(always)] + #[inline(force)] fn each<'a>(&'a self, blk: &fn(v: &'a A) -> bool) -> bool { each(*self, blk) } - #[inline(always)] + #[inline] fn size_hint(&self) -> Option { Some(self.len()) } } // FIXME(#4148): This should be redundant impl old_iter::BaseIter for @[A] { - #[inline(always)] + #[inline(force)] fn each<'a>(&'a self, blk: &fn(v: &'a A) -> bool) -> bool { each(*self, blk) } - #[inline(always)] + #[inline] fn size_hint(&self) -> Option { Some(self.len()) } } impl<'self,A> old_iter::MutableIter for &'self mut [A] { - #[inline(always)] + #[inline(force)] fn each_mut<'a>(&'a mut self, blk: &fn(v: &'a mut A) -> bool) -> bool { each_mut(*self, blk) } @@ -2744,7 +2775,7 @@ impl<'self,A> old_iter::MutableIter for &'self mut [A] { // FIXME(#4148): This should be redundant impl old_iter::MutableIter for ~[A] { - #[inline(always)] + #[inline(force)] fn each_mut<'a>(&'a mut self, blk: &fn(v: &'a mut A) -> bool) -> bool { each_mut(*self, blk) } @@ -2752,13 +2783,14 @@ impl old_iter::MutableIter for ~[A] { // FIXME(#4148): This should be redundant impl old_iter::MutableIter for @mut [A] { - #[inline(always)] + #[inline(force)] fn each_mut(&mut self, blk: &fn(v: &mut A) -> bool) -> bool { each_mut(*self, blk) } } impl<'self,A> old_iter::ExtendedIter for &'self [A] { + #[inline(force)] pub fn eachi(&self, blk: &fn(uint, v: &A) -> bool) -> bool { old_iter::eachi(self, blk) } @@ -2784,7 +2816,7 @@ impl<'self,A> old_iter::ExtendedIter for &'self [A] { } impl<'self,A> old_iter::ExtendedMutableIter for &'self mut [A] { - #[inline(always)] + #[inline(force)] pub fn eachi_mut(&mut self, blk: &fn(uint, v: &mut A) -> bool) -> bool { eachi_mut(*self, blk) } @@ -2792,6 +2824,7 @@ impl<'self,A> old_iter::ExtendedMutableIter for &'self mut [A] { // FIXME(#4148): This should be redundant impl old_iter::ExtendedIter for ~[A] { + #[inline(force)] pub fn eachi(&self, blk: &fn(uint, v: &A) -> bool) -> bool { old_iter::eachi(self, blk) } @@ -2818,6 +2851,7 @@ impl old_iter::ExtendedIter for ~[A] { // FIXME(#4148): This should be redundant impl old_iter::ExtendedIter for @[A] { + #[inline(force)] pub fn eachi(&self, blk: &fn(uint, v: &A) -> bool) -> bool { old_iter::eachi(self, blk) } @@ -2998,7 +3032,7 @@ impl<'self, T> Iterator<&'self mut T> for MutVecIterator<'self, T> { } impl FromIter for ~[T]{ - #[inline(always)] + #[inline(force)] pub fn from_iter(iter: &fn(f: &fn(T) -> bool) -> bool) -> ~[T] { let mut v = ~[]; for iter |x| { v.push(x) } diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index 5bbc5d4e819e0..6d0ecde89a54e 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -95,7 +95,7 @@ impl Decodable for ident { } impl to_bytes::IterBytes for ident { - #[inline(always)] + #[inline(force)] fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) -> bool { self.name.iter_bytes(lsb0, f) } diff --git a/src/libsyntax/ast_util.rs b/src/libsyntax/ast_util.rs index d99363d7ee5f7..54698fc2c2d27 100644 --- a/src/libsyntax/ast_util.rs +++ b/src/libsyntax/ast_util.rs @@ -199,7 +199,7 @@ pub fn is_call_expr(e: @expr) -> bool { // This makes def_id hashable impl to_bytes::IterBytes for def_id { - #[inline(always)] + #[inline(force)] fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) -> bool { self.crate.iter_bytes(lsb0, f) && self.node.iter_bytes(lsb0, f) } diff --git a/src/libsyntax/attr.rs b/src/libsyntax/attr.rs index 2da64563159ed..3e03ab082382b 100644 --- a/src/libsyntax/attr.rs +++ b/src/libsyntax/attr.rs @@ -307,18 +307,21 @@ pub enum inline_attr { ia_none, ia_hint, ia_always, + ia_force, ia_never, } /// True if something like #[inline] is found in the list of attrs. pub fn find_inline_attr(attrs: &[ast::attribute]) -> inline_attr { - // FIXME (#2809)---validate the usage of #[inline] and #[inline(always)] + // FIXME (#2809)---validate the usage of #[inline] and #[inline(force)] do vec::foldl(ia_none, attrs) |ia,attr| { match attr.node.value.node { ast::meta_word(@~"inline") => ia_hint, ast::meta_list(@~"inline", ref items) => { if !find_meta_items_by_name(*items, "always").is_empty() { ia_always + } else if !find_meta_items_by_name(*items, "force").is_empty() { + ia_force } else if !find_meta_items_by_name(*items, "never").is_empty() { ia_never } else { diff --git a/src/libsyntax/ext/deriving/generic.rs b/src/libsyntax/ext/deriving/generic.rs index 2e6cac1876bbb..c86c3fdf05566 100644 --- a/src/libsyntax/ext/deriving/generic.rs +++ b/src/libsyntax/ext/deriving/generic.rs @@ -880,7 +880,7 @@ f(cx, span, ~[self_1.method(__arg_1_1, __arg_2_1), self_2.method(__arg_1_2, __arg_2_2)]) ~~~ */ -#[inline(always)] +#[inline] pub fn cs_same_method(f: &fn(@ExtCtxt, span, ~[@expr]) -> @expr, enum_nonmatch_f: EnumNonMatchFunc, cx: @ExtCtxt, span: span, @@ -911,7 +911,7 @@ Fold together the results of calling the derived method on all the fields. `use_foldl` controls whether this is done left-to-right (`true`) or right-to-left (`false`). */ -#[inline(always)] +#[inline] pub fn cs_same_method_fold(use_foldl: bool, f: &fn(@ExtCtxt, span, @expr, @expr) -> @expr, base: @expr, @@ -939,7 +939,7 @@ pub fn cs_same_method_fold(use_foldl: bool, Use a given binop to combine the result of calling the derived method on all the fields. */ -#[inline(always)] +#[inline] pub fn cs_binop(binop: ast::binop, base: @expr, enum_nonmatch_f: EnumNonMatchFunc, cx: @ExtCtxt, span: span, @@ -958,7 +958,7 @@ pub fn cs_binop(binop: ast::binop, base: @expr, } /// cs_binop with binop == or -#[inline(always)] +#[inline] pub fn cs_or(enum_nonmatch_f: EnumNonMatchFunc, cx: @ExtCtxt, span: span, substructure: &Substructure) -> @expr { @@ -967,7 +967,7 @@ pub fn cs_or(enum_nonmatch_f: EnumNonMatchFunc, cx, span, substructure) } /// cs_binop with binop == and -#[inline(always)] +#[inline] pub fn cs_and(enum_nonmatch_f: EnumNonMatchFunc, cx: @ExtCtxt, span: span, substructure: &Substructure) -> @expr { diff --git a/src/libsyntax/new_visit.rs b/src/libsyntax/new_visit.rs new file mode 100644 index 0000000000000..139597f9cb07c --- /dev/null +++ b/src/libsyntax/new_visit.rs @@ -0,0 +1,2 @@ + + diff --git a/src/libsyntax/opt_vec.rs b/src/libsyntax/opt_vec.rs index 791f7444b6226..73dbd51463a7f 100644 --- a/src/libsyntax/opt_vec.rs +++ b/src/libsyntax/opt_vec.rs @@ -103,7 +103,7 @@ impl OptVec { } } - #[inline(always)] + #[inline(force)] fn mapi_to_vec(&self, op: &fn(uint, &T) -> B) -> ~[B] { let mut index = 0; old_iter::map_to_vec(self, |a| { @@ -145,31 +145,31 @@ impl BaseIter for OptVec { } impl old_iter::ExtendedIter for OptVec { - #[inline(always)] + #[inline(force)] fn eachi(&self, blk: &fn(v: uint, v: &A) -> bool) -> bool { old_iter::eachi(self, blk) } - #[inline(always)] + #[inline(force)] fn all(&self, blk: &fn(&A) -> bool) -> bool { old_iter::all(self, blk) } - #[inline(always)] + #[inline(force)] fn any(&self, blk: &fn(&A) -> bool) -> bool { old_iter::any(self, blk) } - #[inline(always)] + #[inline(force)] fn foldl(&self, b0: B, blk: &fn(&B, &A) -> B) -> B { old_iter::foldl(self, b0, blk) } - #[inline(always)] + #[inline(force)] fn position(&self, f: &fn(&A) -> bool) -> Option { old_iter::position(self, f) } - #[inline(always)] + #[inline(force)] fn map_to_vec(&self, op: &fn(&A) -> B) -> ~[B] { old_iter::map_to_vec(self, op) } - #[inline(always)] + #[inline(force)] fn flat_map_to_vec>(&self, op: &fn(&A) -> IB) -> ~[B] { old_iter::flat_map_to_vec(self, op) @@ -178,28 +178,28 @@ impl old_iter::ExtendedIter for OptVec { } impl old_iter::EqIter for OptVec { - #[inline(always)] + #[inline] fn contains(&self, x: &A) -> bool { old_iter::contains(self, x) } - #[inline(always)] + #[inline] fn count(&self, x: &A) -> uint { old_iter::count(self, x) } } impl old_iter::CopyableIter for OptVec { - #[inline(always)] + #[inline(force)] fn filter_to_vec(&self, pred: &fn(&A) -> bool) -> ~[A] { old_iter::filter_to_vec(self, pred) } - #[inline(always)] + #[inline] fn to_vec(&self) -> ~[A] { old_iter::to_vec(self) } - #[inline(always)] + #[inline(force)] fn find(&self, f: &fn(&A) -> bool) -> Option { old_iter::find(self, f) } } impl old_iter::CopyableOrderedIter for OptVec { - #[inline(always)] + #[inline(force)] fn min(&self) -> A { old_iter::min(self) } - #[inline(always)] + #[inline(force)] fn max(&self) -> A { old_iter::max(self) } } diff --git a/src/libsyntax/parse/obsolete.rs b/src/libsyntax/parse/obsolete.rs index 61b7f1403e642..1611337afb6d8 100644 --- a/src/libsyntax/parse/obsolete.rs +++ b/src/libsyntax/parse/obsolete.rs @@ -68,7 +68,7 @@ pub enum ObsoleteSyntax { } impl to_bytes::IterBytes for ObsoleteSyntax { - #[inline(always)] + #[inline(force)] fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) -> bool { (*self as uint).iter_bytes(lsb0, f) } diff --git a/src/libsyntax/parse/token.rs b/src/libsyntax/parse/token.rs index ecf83483c21fe..79919ee4136d1 100644 --- a/src/libsyntax/parse/token.rs +++ b/src/libsyntax/parse/token.rs @@ -354,12 +354,12 @@ pub mod special_idents { pub struct StringRef<'self>(&'self str); impl<'self> Equiv<@~str> for StringRef<'self> { - #[inline(always)] + #[inline] fn equiv(&self, other: &@~str) -> bool { str::eq_slice(**self, **other) } } impl<'self> to_bytes::IterBytes for StringRef<'self> { - #[inline(always)] + #[inline(force)] fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) -> bool { (**self).iter_bytes(lsb0, f) }