summaryrefslogtreecommitdiff
path: root/src/sys/stat.rs
diff options
context:
space:
mode:
authorAlan Somers <asomers@gmail.com>2018-11-28 10:47:12 -0700
committerAlan Somers <asomers@gmail.com>2018-11-28 10:47:12 -0700
commitcdf730ca3cdc5ce7dfb284986d39398ac23187b2 (patch)
treee4110799ae4eb5e14dd1881051288dafa624e885 /src/sys/stat.rs
parent3609e6f725e3fe6d830d78bc2d2b36202ea5d790 (diff)
downloadnix-cdf730ca3cdc5ce7dfb284986d39398ac23187b2.zip
Prefer `map(drop)` to `map(|_| ())`
I previously advocated for the latter syntax on stylistic grounds. But it generates less efficient code, because it creates a new lambda function for each usage. The optimizer does not combine them. This change saves about 6KB of code.
Diffstat (limited to 'src/sys/stat.rs')
-rw-r--r--src/sys/stat.rs12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/sys/stat.rs b/src/sys/stat.rs
index 925c0ede..f3a2e7e3 100644
--- a/src/sys/stat.rs
+++ b/src/sys/stat.rs
@@ -131,7 +131,7 @@ pub fn fstatat<P: ?Sized + NixPath>(dirfd: RawFd, pathname: &P, f: AtFlags) -> R
pub fn fchmod(fd: RawFd, mode: Mode) -> Result<()> {
let res = unsafe { libc::fchmod(fd, mode.bits() as mode_t) };
- Errno::result(res).map(|_| ())
+ Errno::result(res).map(drop)
}
/// Flags for `fchmodat` function.
@@ -177,7 +177,7 @@ pub fn fchmodat<P: ?Sized + NixPath>(
)
})?;
- Errno::result(res).map(|_| ())
+ Errno::result(res).map(drop)
}
/// Change the access and modification times of a file.
@@ -196,7 +196,7 @@ pub fn utimes<P: ?Sized + NixPath>(path: &P, atime: &TimeVal, mtime: &TimeVal) -
libc::utimes(cstr.as_ptr(), &times[0])
})?;
- Errno::result(res).map(|_| ())
+ Errno::result(res).map(drop)
}
/// Change the access and modification times of a file without following symlinks.
@@ -216,7 +216,7 @@ pub fn lutimes<P: ?Sized + NixPath>(path: &P, atime: &TimeVal, mtime: &TimeVal)
libc::lutimes(cstr.as_ptr(), &times[0])
})?;
- Errno::result(res).map(|_| ())
+ Errno::result(res).map(drop)
}
/// Change the access and modification times of the file specified by a file descriptor.
@@ -229,7 +229,7 @@ pub fn futimens(fd: RawFd, atime: &TimeSpec, mtime: &TimeSpec) -> Result<()> {
let times: [libc::timespec; 2] = [*atime.as_ref(), *mtime.as_ref()];
let res = unsafe { libc::futimens(fd, &times[0]) };
- Errno::result(res).map(|_| ())
+ Errno::result(res).map(drop)
}
/// Flags for `utimensat` function.
@@ -277,5 +277,5 @@ pub fn utimensat<P: ?Sized + NixPath>(
)
})?;
- Errno::result(res).map(|_| ())
+ Errno::result(res).map(drop)
}