From d61436211637a9eb9e79b8560c6dd4ec930ee43c Mon Sep 17 00:00:00 2001 From: Heiko Thiel Date: Fri, 3 May 2019 17:45:14 +0200 Subject: Add const keyword to variables of for-ranged loops --- src/GPSFix.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/GPSFix.cpp') diff --git a/src/GPSFix.cpp b/src/GPSFix.cpp index ac4e019..e45efbc 100644 --- a/src/GPSFix.cpp +++ b/src/GPSFix.cpp @@ -71,13 +71,13 @@ double GPSAlmanac::averageSNR(){ double avg = 0; double relevant = 0; - for (auto& satellite : satellites){ + for (const auto& satellite : satellites){ if (satellite.snr > 0){ relevant += 1.0; } } - for (auto& satellite : satellites){ + for (const auto& satellite : satellites){ if (satellite.snr > 0){ avg += satellite.snr / relevant; } @@ -91,7 +91,7 @@ double GPSAlmanac::minSNR(){ return 0; } int32_t num_over_zero = 0; - for (auto& satellite : satellites){ + for (const auto& satellite : satellites){ if (satellite.snr > 0){ num_over_zero++; if (satellite.snr < min){ @@ -107,7 +107,7 @@ double GPSAlmanac::minSNR(){ double GPSAlmanac::maxSNR(){ double max = 0; - for (auto& satellite : satellites){ + for (const auto& satellite : satellites){ if (satellite.snr > 0){ if (satellite.snr > max){ max = satellite.snr; -- cgit v1.2.3