summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHeiko Thiel <heiko.thiel@hpi.de>2019-05-03 17:45:14 +0200
committerHeiko Thiel <heiko.thiel@hpi.de>2019-05-03 17:45:14 +0200
commitd61436211637a9eb9e79b8560c6dd4ec930ee43c (patch)
treec6118023f87d69663ad6bba58027aacb37806806 /src
parent231dfc176e1ae56f30554fc4fd188286640a4864 (diff)
Add const keyword to variables of for-ranged loops
Diffstat (limited to 'src')
-rw-r--r--src/GPSFix.cpp8
-rw-r--r--src/NMEAParser.cpp12
2 files changed, 10 insertions, 10 deletions
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;
diff --git a/src/NMEAParser.cpp b/src/NMEAParser.cpp
index 4560b30..14084c2 100644
--- a/src/NMEAParser.cpp
+++ b/src/NMEAParser.cpp
@@ -64,7 +64,7 @@ bool NMEASentence::checksumOK() const {
// true if the text contains a non-alpha numeric value
bool hasNonAlphaNum(string txt){
- for (char i : txt){
+ for (const char i : txt){
if ( !isalnum(i) ){
return true;
}
@@ -74,7 +74,7 @@ bool hasNonAlphaNum(string txt){
// true if alphanumeric or '-'
bool validParamChars(string txt){
- for (char i : txt){
+ for (const char i : txt){
if (!isalnum(i)){
if (i != '-' && i != '.'){
return false;
@@ -88,7 +88,7 @@ bool validParamChars(string txt){
void squish(string& str){
char chars[] = {'\t',' '};
- for (char i : chars)
+ for (const char i : chars)
{
// needs include <algorithm>
str.erase(std::remove(str.begin(), str.end(), i), str.end());
@@ -129,7 +129,7 @@ string NMEAParser::getRegisteredSentenceHandlersCSV()
}
ostringstream ss;
- for(auto& table : eventTable){
+ for(const auto& table : eventTable){
ss << table.first;
if( ! table.second ){
@@ -188,7 +188,7 @@ void NMEAParser::readBuffer(uint8_t* b, uint32_t size){
void NMEAParser::readLine(string cmd){
cmd += "\r\n";
- for (char i : cmd){
+ for (const char i : cmd){
readByte(i);
}
}
@@ -306,7 +306,7 @@ void NMEAParser::readSentence(std::string cmd){
// then calculates a rolling XOR on the bytes
uint8_t NMEAParser::calculateChecksum(string s){
uint8_t checksum = 0;
- for (char i : s){
+ for (const char i : s){
checksum = checksum ^ i;
}