diff options
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/command_executor.cpp | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/src/main/command_executor.cpp b/src/main/command_executor.cpp index a7666dfcf..94c0c9e23 100644 --- a/src/main/command_executor.cpp +++ b/src/main/command_executor.cpp @@ -260,26 +260,29 @@ void CommandExecutor::printStatsFilterZeros(std::ostream& out, std::getline(iss, statName, ','); - while( !iss.eof() ) { - + while (!iss.eof()) + { std::getline(iss, statValue, '\n'); - double curFloat; - std::istringstream iss_stat_value (statValue); - iss_stat_value >> curFloat; - bool isFloat = iss_stat_value.good(); + bool skip = false; + try + { + double dval = std::stod(statValue); + skip = (dval == 0.0); + } + // Value can not be converted, don't skip + catch (const std::invalid_argument&) {} + catch (const std::out_of_range&) {} - if( (isFloat && curFloat == 0) || - statValue == " \"0\"" || - statValue == " \"[]\"") { - // skip - } else { + skip = skip || (statValue == " \"0\"" || statValue == " \"[]\""); + + if (!skip) + { out << statName << "," << statValue << std::endl; } std::getline(iss, statName, ','); } - } void CommandExecutor::flushOutputStreams() { |