From c4b26783c75ae8ea56841d8cc444b863f2452b2c Mon Sep 17 00:00:00 2001 From: Maximilian Roos Date: Thu, 11 Jul 2019 11:47:27 -0400 Subject: [PATCH] clippy lint pending perf check --- src/numeric_util.rs | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) 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