diff --git a/src/numeric_util.rs b/src/numeric_util.rs index 6ad0bb0a5..b89196a21 100644 --- a/src/numeric_util.rs +++ b/src/numeric_util.rs @@ -5,9 +5,6 @@ // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. - -// https://github.com/rust-ndarray/ndarray/pull/642#discussion_r296074711 -#![allow(clippy::needless_range_loop)] use std::cmp; use crate::LinalgScalar; @@ -51,12 +48,11 @@ where // make it clear to the optimizer that this loop is short // and can not be autovectorized. - // https://github.com/rust-ndarray/ndarray/pull/642#discussion_r296337112 - for i in 0..xs.len() { + for (i, x) in xs.iter().enumerate() { if i >= 7 { break; } - acc = f(acc.clone(), xs[i].clone()) + acc = f(acc.clone(), x.clone()) } acc } @@ -103,13 +99,13 @@ where sum = sum + (p2 + p6); sum = sum + (p3 + p7); - for i in 0..xs.len() { + for (i, x) in xs.iter().enumerate() { if i >= 7 { break; } unsafe { // get_unchecked is needed to avoid the bounds check - sum = sum + xs[i] * *ys.get_unchecked(i); + sum = sum + *x * *ys.get_unchecked(i); } } sum