From cdf730ca3cdc5ce7dfb284986d39398ac23187b2 Mon Sep 17 00:00:00 2001 From: Alan Somers Date: Wed, 28 Nov 2018 10:47:12 -0700 Subject: 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. --- src/sys/aio.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/sys/aio.rs') diff --git a/src/sys/aio.rs b/src/sys/aio.rs index 3d539821..c54c2e31 100644 --- a/src/sys/aio.rs +++ b/src/sys/aio.rs @@ -1138,7 +1138,7 @@ impl<'a> LioCb<'a> { let p = self.list.as_ptr(); Errno::result(unsafe { libc::lio_listio(mode as i32, p, self.list.len() as i32, sigevp) - }).map(|_| ()) + }).map(drop) } /// Resubmits any incomplete operations with [`lio_listio`]. @@ -1229,7 +1229,7 @@ impl<'a> LioCb<'a> { let p = self.list.as_ptr(); Errno::result(unsafe { libc::lio_listio(mode as i32, p, self.list.len() as i32, sigevp) - }).map(|_| ()) + }).map(drop) } /// Collect final status for an individual `AioCb` submitted as part of an -- cgit v1.2.3