Skip to content

Commit f218812

Browse files
committed
Add #[inline] attributes to small functions.
These functions inline into a small number of instructions, so mark them `#[inline]`.
1 parent b0cd095 commit f218812

3 files changed

Lines changed: 9 additions & 0 deletions

File tree

src/imp/linux_raw/io/syscalls.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ pub(crate) fn pread(fd: BorrowedFd<'_>, buf: &mut [u8], pos: u64) -> io::Result<
120120
}
121121
}
122122

123+
#[inline]
123124
pub(crate) fn readv(fd: BorrowedFd<'_>, bufs: &mut [IoSliceMut<'_>]) -> io::Result<usize> {
124125
let (bufs_addr, bufs_len) = slice(&bufs[..cmp::min(bufs.len(), max_iov())]);
125126

@@ -133,6 +134,7 @@ pub(crate) fn readv(fd: BorrowedFd<'_>, bufs: &mut [IoSliceMut<'_>]) -> io::Resu
133134
}
134135
}
135136

137+
#[inline]
136138
pub(crate) fn preadv(
137139
fd: BorrowedFd<'_>,
138140
bufs: &mut [IoSliceMut<'_>],
@@ -163,6 +165,7 @@ pub(crate) fn preadv(
163165
}
164166
}
165167

168+
#[inline]
166169
pub(crate) fn preadv2(
167170
fd: BorrowedFd<'_>,
168171
bufs: &mut [IoSliceMut<'_>],

src/imp/linux_raw/process/syscalls.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ pub(crate) fn getcwd(buf: &mut [u8]) -> io::Result<usize> {
5858
unsafe { ret_usize(syscall2(nr(__NR_getcwd), buf_addr_mut, buf_len)) }
5959
}
6060

61+
#[inline]
6162
pub(crate) fn membarrier_query() -> MembarrierQuery {
6263
unsafe {
6364
match ret_c_uint(syscall2(
@@ -79,6 +80,7 @@ pub(crate) fn membarrier_query() -> MembarrierQuery {
7980
}
8081
}
8182

83+
#[inline]
8284
pub(crate) fn membarrier(cmd: MembarrierCommand) -> io::Result<()> {
8385
unsafe {
8486
ret(syscall2(
@@ -89,6 +91,7 @@ pub(crate) fn membarrier(cmd: MembarrierCommand) -> io::Result<()> {
8991
}
9092
}
9193

94+
#[inline]
9295
pub(crate) fn membarrier_cpu(cmd: MembarrierCommand, cpu: Cpuid) -> io::Result<()> {
9396
unsafe {
9497
ret(syscall3(

src/path/arg.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,15 @@ pub trait Arg {
7979

8080
/// Returns a view of this string as a maybe-owned [`ZStr`].
8181
#[cfg(not(feature = "rustc-dep-of-std"))]
82+
#[inline]
8283
fn as_cow_c_str(&self) -> io::Result<Cow<'_, ZStr>> {
8384
self.as_cow_z_str()
8485
}
8586

8687
/// Consumes `self` and returns a view of this string as a maybe-owned
8788
/// [`ZStr`].
8889
#[cfg(not(feature = "rustc-dep-of-std"))]
90+
#[inline]
8991
fn into_c_str<'b>(self) -> io::Result<Cow<'b, ZStr>>
9092
where
9193
Self: 'b + Sized,
@@ -95,6 +97,7 @@ pub trait Arg {
9597

9698
/// Runs a closure with `self` passed in as a `&ZStr`.
9799
#[cfg(not(feature = "rustc-dep-of-std"))]
100+
#[inline]
98101
fn into_with_c_str<T, F>(self, f: F) -> io::Result<T>
99102
where
100103
Self: Sized,

0 commit comments

Comments
 (0)