More decorative fixes

This commit is contained in:
elevankoff 2021-05-24 17:24:29 +00:00
parent 067ec0855c
commit 6bf0840562
3 changed files with 43 additions and 41 deletions

View File

@ -16,18 +16,18 @@ namespace DB
namespace namespace
{ {
template<typename T> template<typename T>
void readIntTextAndSkipWhitespaceIfAny(T & x, ReadBuffer & buf) void readIntTextAndSkipWhitespaceIfAny(T & x, ReadBuffer & buf)
{ {
readIntText(x, buf); readIntText(x, buf);
skipWhitespaceIfAny(buf); skipWhitespaceIfAny(buf);
} }
void readStringUntilWhitespaceAndSkipWhitespaceIfAny(String & s, ReadBuffer & buf) void readStringUntilWhitespaceAndSkipWhitespaceIfAny(String & s, ReadBuffer & buf)
{ {
readStringUntilWhitespace(s, buf); readStringUntilWhitespace(s, buf);
skipWhitespaceIfAny(buf); skipWhitespaceIfAny(buf);
} }
} }
static constexpr auto meminfo_filename = "/proc/meminfo"; static constexpr auto meminfo_filename = "/proc/meminfo";

View File

@ -23,36 +23,36 @@ namespace DB
namespace namespace
{ {
template<typename T> template<typename T>
void readIntTextAndSkipWhitespaceIfAny(T & x, ReadBuffer & buf) void readIntTextAndSkipWhitespaceIfAny(T & x, ReadBuffer & buf)
{ {
readIntText(x, buf); readIntText(x, buf);
skipWhitespaceIfAny(buf); skipWhitespaceIfAny(buf);
} }
void readStringAndSkipWhitespaceIfAny(String & s, ReadBuffer & buf) void readStringAndSkipWhitespaceIfAny(String & s, ReadBuffer & buf)
{ {
readString(s, buf); readString(s, buf);
skipWhitespaceIfAny(buf); skipWhitespaceIfAny(buf);
} }
void readStringUntilWhitespaceAndSkipWhitespaceIfAny(String & s, ReadBuffer & buf) void readStringUntilWhitespaceAndSkipWhitespaceIfAny(String & s, ReadBuffer & buf)
{ {
readStringUntilWhitespace(s, buf); readStringUntilWhitespace(s, buf);
skipWhitespaceIfAny(buf); skipWhitespaceIfAny(buf);
} }
void readCharAndSkipWhitespaceIfAny(char & c, ReadBuffer & buf) void readCharAndSkipWhitespaceIfAny(char & c, ReadBuffer & buf)
{ {
readChar(c, buf); readChar(c, buf);
skipWhitespaceIfAny(buf); skipWhitespaceIfAny(buf);
} }
void readFloatAndSkipWhitespaceIfAny(float & f, ReadBuffer & buf) void readFloatAndSkipWhitespaceIfAny(float & f, ReadBuffer & buf)
{ {
readFloatText(f, buf); readFloatText(f, buf);
skipWhitespaceIfAny(buf); skipWhitespaceIfAny(buf);
} }
} }
static constexpr auto loadavg_filename = "/proc/loadavg"; static constexpr auto loadavg_filename = "/proc/loadavg";
@ -140,7 +140,8 @@ void ProcessorStatisticsOS::readProcTimeAndProcesses(ProcTime & proc_time, ProcS
proc_time.guest /= USER_HZ; proc_time.guest /= USER_HZ;
proc_time.guest_nice /= USER_HZ; proc_time.guest_nice /= USER_HZ;
do { do
{
readStringUntilWhitespaceAndSkipWhitespaceIfAny(field_name, procst_in); readStringUntilWhitespaceAndSkipWhitespaceIfAny(field_name, procst_in);
readStringAndSkipWhitespaceIfAny(field_val, procst_in); readStringAndSkipWhitespaceIfAny(field_val, procst_in);
} while (field_name != String("processes")); } while (field_name != String("processes"));
@ -163,8 +164,10 @@ void ProcessorStatisticsOS::readFreq(ProcFreq & freq)
int cpu_count = 0; int cpu_count = 0;
freq.max = freq.min = freq.avg = 0; freq.max = freq.min = freq.avg = 0;
do { do
do { {
do
{
readStringAndSkipWhitespaceIfAny(field_name, cpuinfo_in); readStringAndSkipWhitespaceIfAny(field_name, cpuinfo_in);
} while (!cpuinfo_in.eof() && field_name != String("cpu MHz")); } while (!cpuinfo_in.eof() && field_name != String("cpu MHz"));

View File

@ -18,7 +18,6 @@ namespace DB
class ProcessorStatisticsOS class ProcessorStatisticsOS
{ {
public: public:
struct ProcLoadavg struct ProcLoadavg
{ {
float avg1; float avg1;