Skip to content

Commit c67d518

Browse files
committed
add various #[inline] directives
1 parent 24ab375 commit c67d518

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/librustc_data_structures/indexed_vec.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,53 +155,63 @@ macro_rules! newtype_index {
155155
}
156156

157157
impl ::std::iter::Step for $type {
158+
#[inline]
158159
fn steps_between(start: &Self, end: &Self) -> Option<usize> {
159160
<usize as ::std::iter::Step>::steps_between(
160161
&Idx::index(*start),
161162
&Idx::index(*end),
162163
)
163164
}
164165

166+
#[inline]
165167
fn replace_one(&mut self) -> Self {
166168
::std::mem::replace(self, Self::new(1))
167169
}
168170

171+
#[inline]
169172
fn replace_zero(&mut self) -> Self {
170173
::std::mem::replace(self, Self::new(0))
171174
}
172175

176+
#[inline]
173177
fn add_one(&self) -> Self {
174178
Self::new(Idx::index(*self) + 1)
175179
}
176180

181+
#[inline]
177182
fn sub_one(&self) -> Self {
178183
Self::new(Idx::index(*self) - 1)
179184
}
180185

186+
#[inline]
181187
fn add_usize(&self, u: usize) -> Option<Self> {
182188
Idx::index(*self).checked_add(u).map(Self::new)
183189
}
184190
}
185191

186192
impl From<$type> for u32 {
193+
#[inline]
187194
fn from(v: $type) -> u32 {
188195
v.as_u32()
189196
}
190197
}
191198

192199
impl From<$type> for usize {
200+
#[inline]
193201
fn from(v: $type) -> usize {
194202
v.as_usize()
195203
}
196204
}
197205

198206
impl From<usize> for $type {
207+
#[inline]
199208
fn from(value: usize) -> Self {
200209
$type::from_usize(value)
201210
}
202211
}
203212

204213
impl From<u32> for $type {
214+
#[inline]
205215
fn from(value: u32) -> Self {
206216
$type::from_u32(value)
207217
}

0 commit comments

Comments
 (0)