From bed6364dcb7c719377b17b7c421a306a3f980a3d Mon Sep 17 00:00:00 2001 From: Stephen Chung Date: Wed, 28 Oct 2020 22:30:29 +0800 Subject: [PATCH] Simplify hash calculation. --- src/utils.rs | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/src/utils.rs b/src/utils.rs index 7596b6cb..451b929a 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -122,19 +122,11 @@ fn calc_fn_hash<'a>( // We always skip the first module modules.skip(1).for_each(|m| m.hash(s)); s.write(fn_name.as_bytes()); - let num = if let Some(num) = num { - num + if let Some(num) = num { + s.write_usize(num); } else { - let mut count = 0; - - params.for_each(|t| { - count += 1; - t.hash(s); - }); - - count - }; - s.write_usize(num); + params.for_each(|t| t.hash(s)); + } s.finish() }