Skip to content

Commit 1483c6d

Browse files
committed
FIX: Adjust (mostly remove) inline directives
Using the following principles: - Trivial methods (empty and simple constants) can be inline(always) - Generic methods don't need any inlining directive at all. ..with the exception of Deref which just seems to be extra important. - Non-generic items use #[inline] to enable inlining at the compiler's discretion.
1 parent bf64376 commit 1483c6d

File tree

3 files changed

+2
-20
lines changed

3 files changed

+2
-20
lines changed

src/array.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,8 @@ macro_rules! fix_array_impl {
8787
type Index = $index_type;
8888
const CAPACITY: usize = $len;
8989
#[doc(hidden)]
90-
#[inline]
9190
fn as_slice(&self) -> &[Self::Item] { self }
9291
#[doc(hidden)]
93-
#[inline]
9492
fn as_mut_slice(&mut self) -> &mut [Self::Item] { self }
9593
}
9694
)

src/array_string.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ impl<A> ArrayString<A>
113113
/// let string = ArrayString::<[_; 3]>::new();
114114
/// assert_eq!(string.capacity(), 3);
115115
/// ```
116-
#[inline]
116+
#[inline(always)]
117117
pub fn capacity(&self) -> usize { A::CAPACITY }
118118

119119
/// Return if the `ArrayString` is completely filled.
@@ -244,7 +244,6 @@ impl<A> ArrayString<A>
244244
///
245245
/// assert_eq!(s.pop(), None);
246246
/// ```
247-
#[inline]
248247
pub fn pop(&mut self) -> Option<char> {
249248
let ch = match self.chars().rev().next() {
250249
Some(ch) => ch,
@@ -273,7 +272,6 @@ impl<A> ArrayString<A>
273272
/// string.truncate(4);
274273
/// assert_eq!(&string[..], "foo");
275274
/// ```
276-
#[inline]
277275
pub fn truncate(&mut self, new_len: usize) {
278276
if new_len <= self.len() {
279277
assert!(self.is_char_boundary(new_len));
@@ -304,7 +302,6 @@ impl<A> ArrayString<A>
304302
/// assert_eq!(s.remove(1), 'o');
305303
/// assert_eq!(s.remove(0), 'o');
306304
/// ```
307-
#[inline]
308305
pub fn remove(&mut self, idx: usize) -> char {
309306
let ch = match self[idx..].chars().next() {
310307
Some(ch) => ch,
@@ -336,7 +333,6 @@ impl<A> ArrayString<A>
336333
///
337334
/// This method uses *debug assertions* to check the validity of `length`
338335
/// and may use other debug assertions.
339-
#[inline]
340336
pub unsafe fn set_len(&mut self, length: usize) {
341337
debug_assert!(length <= self.capacity());
342338
self.len = Index::from(length);

src/lib.rs

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ impl<A: Array> ArrayVec<A> {
134134
/// let array = ArrayVec::from([1, 2, 3]);
135135
/// assert_eq!(array.capacity(), 3);
136136
/// ```
137-
#[inline]
137+
#[inline(always)]
138138
pub fn capacity(&self) -> usize { A::CAPACITY }
139139

140140
/// Return if the `ArrayVec` is completely filled.
@@ -235,7 +235,6 @@ impl<A: Array> ArrayVec<A> {
235235
///
236236
/// assert_eq!(&array[..], &[1, 2]);
237237
/// ```
238-
#[inline]
239238
pub unsafe fn push_unchecked(&mut self, element: A::Item) {
240239
let len = self.len();
241240
debug_assert!(len < A::CAPACITY);
@@ -507,7 +506,6 @@ impl<A: Array> ArrayVec<A> {
507506
///
508507
/// This method uses *debug assertions* to check that `length` is
509508
/// not greater than the capacity.
510-
#[inline]
511509
pub unsafe fn set_len(&mut self, length: usize) {
512510
debug_assert!(length <= self.capacity());
513511
self.len = Index::from(length);
@@ -755,7 +753,6 @@ pub struct IntoIter<A: Array> {
755753
impl<A: Array> Iterator for IntoIter<A> {
756754
type Item = A::Item;
757755

758-
#[inline]
759756
fn next(&mut self) -> Option<A::Item> {
760757
if self.index == self.v.len {
761758
None
@@ -775,7 +772,6 @@ impl<A: Array> Iterator for IntoIter<A> {
775772
}
776773

777774
impl<A: Array> DoubleEndedIterator for IntoIter<A> {
778-
#[inline]
779775
fn next_back(&mut self) -> Option<A::Item> {
780776
if self.index == self.v.len {
781777
None
@@ -852,7 +848,6 @@ impl<'a, A: Array> Iterator for Drain<'a, A>
852848
{
853849
type Item = A::Item;
854850

855-
#[inline]
856851
fn next(&mut self) -> Option<Self::Item> {
857852
self.iter.next().map(|elt|
858853
unsafe {
@@ -861,7 +856,6 @@ impl<'a, A: Array> Iterator for Drain<'a, A>
861856
)
862857
}
863858

864-
#[inline]
865859
fn size_hint(&self) -> (usize, Option<usize>) {
866860
self.iter.size_hint()
867861
}
@@ -870,7 +864,6 @@ impl<'a, A: Array> Iterator for Drain<'a, A>
870864
impl<'a, A: Array> DoubleEndedIterator for Drain<'a, A>
871865
where A::Item: 'a,
872866
{
873-
#[inline]
874867
fn next_back(&mut self) -> Option<Self::Item> {
875868
self.iter.next_back().map(|elt|
876869
unsafe {
@@ -1069,27 +1062,22 @@ impl<A: Array> Default for ArrayVec<A> {
10691062
}
10701063

10711064
impl<A: Array> PartialOrd for ArrayVec<A> where A::Item: PartialOrd {
1072-
#[inline]
10731065
fn partial_cmp(&self, other: &ArrayVec<A>) -> Option<cmp::Ordering> {
10741066
(**self).partial_cmp(other)
10751067
}
10761068

1077-
#[inline]
10781069
fn lt(&self, other: &Self) -> bool {
10791070
(**self).lt(other)
10801071
}
10811072

1082-
#[inline]
10831073
fn le(&self, other: &Self) -> bool {
10841074
(**self).le(other)
10851075
}
10861076

1087-
#[inline]
10881077
fn ge(&self, other: &Self) -> bool {
10891078
(**self).ge(other)
10901079
}
10911080

1092-
#[inline]
10931081
fn gt(&self, other: &Self) -> bool {
10941082
(**self).gt(other)
10951083
}

0 commit comments

Comments
 (0)