From e26c27f58df688d7bfb2185ad54d4fe010b1fccf Mon Sep 17 00:00:00 2001 From: Joel Natividad <1980690+jqnatividad@users.noreply.github.com> Date: Sat, 19 Oct 2024 18:01:16 -0400 Subject: [PATCH] `stats`: use unwrap_unchecked instead of unwrap in perf-critical hot loop we already use unwrap amyway, might as well use unwrap_unchecked for stuff we know will not panic to get rid of panic code --- src/cmd/stats.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/cmd/stats.rs b/src/cmd/stats.rs index 9ff7c2b06..2b0405b2c 100644 --- a/src/cmd/stats.rs +++ b/src/cmd/stats.rs @@ -951,12 +951,19 @@ impl Args { // if it does return an Err, you have a bigger problem as the index file was // modified WHILE stats is running and you NEED to abort if that // happens, however unlikely - let mut idx = args.rconfig().indexed().unwrap().unwrap(); + let mut idx = unsafe { + args.rconfig() + .indexed() + .unwrap_unchecked() + .unwrap_unchecked() + }; idx.seek((i * chunk_size) as u64) .expect("File seek failed."); let it = idx.byte_records().take(chunk_size); // safety: this will only return an Error if the channel has been disconnected - send.send(args.compute(&sel, it)).unwrap(); + unsafe { + send.send(args.compute(&sel, it)).unwrap_unchecked(); + } }); } drop(send);