From 752ca9fad36b7ef6ec67dfd9e09a65ac25e48d4f Mon Sep 17 00:00:00 2001 From: Thomas Fischer <thomas.fischer@ufz.de> Date: Mon, 21 Jun 2021 08:44:16 +0200 Subject: [PATCH] [GL/SensorData] Early return + constify data. --- GeoLib/SensorData.cpp | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/GeoLib/SensorData.cpp b/GeoLib/SensorData.cpp index 97e76245440..71093b40b8b 100644 --- a/GeoLib/SensorData.cpp +++ b/GeoLib/SensorData.cpp @@ -154,24 +154,22 @@ int SensorData::readDataFromFile(const std::string& file_name) { fields = BaseLib::splitString(line, '\t'); - if (nFields == fields.size()) + if (nFields != fields.size()) { - it = fields.begin(); - std::size_t pos(it->rfind(".")); - std::size_t current_time_step = (pos == std::string::npos) - ? atoi((it++)->c_str()) - : BaseLib::strDate2int(*it++); - this->_time_steps.push_back(current_time_step); - - for (std::size_t i = 0; i < nDataArrays; i++) - { - this->_data_vecs[i]->push_back( - static_cast<float>(strtod((it++)->c_str(), nullptr))); - } + return 0; } - else + + it = fields.begin(); + std::size_t const pos(it->rfind(".")); + std::size_t const current_time_step = (pos == std::string::npos) + ? atoi((it++)->c_str()) + : BaseLib::strDate2int(*it++); + this->_time_steps.push_back(current_time_step); + + for (std::size_t i = 0; i < nDataArrays; i++) { - return 0; + this->_data_vecs[i]->push_back( + static_cast<float>(strtod((it++)->c_str(), nullptr))); } } -- GitLab