Skip to content

Commit

Permalink
Reduce an instance of direct indexing
Browse files Browse the repository at this point in the history
  • Loading branch information
keithtensor committed Jul 1, 2024
1 parent fa55e84 commit 24361e0
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pallets/subtensor/src/math.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]];
Expand Down

0 comments on commit 24361e0

Please sign in to comment.