Speed dropped_percent() common case, ensure dropped>0 returns >0%.

This commit is contained in:
Jared Boone 2016-04-27 12:16:37 -07:00
parent be9f3362da
commit dc8c34487f

View File

@ -26,6 +26,7 @@
#include <cstddef> #include <cstddef>
#include <array> #include <array>
#include <functional> #include <functional>
#include <algorithm>
#include "baseband_packet.hpp" #include "baseband_packet.hpp"
#include "ert_packet.hpp" #include "ert_packet.hpp"
@ -429,7 +430,12 @@ struct CaptureConfig {
} }
size_t dropped_percent() const { size_t dropped_percent() const {
return baseband_bytes_dropped * 100U / baseband_bytes_received; if( baseband_bytes_dropped == 0 ) {
return 0;
} else {
const size_t percent = baseband_bytes_dropped * 100U / baseband_bytes_received;
return std::max(1U, percent);
}
} }
}; };