From 24361e08ef9e549b673cf2a49e886d1ff5e3b7a5 Mon Sep 17 00:00:00 2001 From: Keith Date: Mon, 1 Jul 2024 17:18:42 +0200 Subject: [PATCH] Reduce an instance of direct indexing --- pallets/subtensor/src/math.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pallets/subtensor/src/math.rs b/pallets/subtensor/src/math.rs index 57d803f5e..af3453bcf 100644 --- a/pallets/subtensor/src/math.rs +++ b/pallets/subtensor/src/math.rs @@ -866,8 +866,8 @@ pub fn weighted_median( let mut current_partition_idx = partition_idx.to_vec(); while !current_partition_idx.is_empty() { let n = current_partition_idx.len(); - if n == 1 { - return score[current_partition_idx[0]]; + if let Some(first_idx) = current_partition_idx.first() { + return score[*first_idx]; } let mid_idx: usize = n / 2; let pivot: I32F32 = score[current_partition_idx[mid_idx]];