diff options
author | Explorer09 <explorer09@gmail.com> | 2023-10-11 01:57:29 +0800 |
---|---|---|
committer | BenBE <BenBE@geshi.org> | 2023-10-10 21:57:39 +0200 |
commit | 9c3e1d4e6422e391b52138ea9ea78db32dc48668 (patch) | |
tree | 70b2e378396a89328507e15ce521a0cc24077024 /Meter.c | |
parent | 74b28849c4ee7234aa6018667ff6c8c9a6b41273 (diff) |
Reorder some GraphMeterMode_draw() code
In particular, move the code for adding a new graph record to before
the GraphMeterMode_dots selection code. (The latter is the drawing part
of the function.)
Signed-off-by: Kang-Che Sung <explorer09@gmail.com>
Diffstat (limited to 'Meter.c')
-rw-r--r-- | Meter.c | 25 |
1 files changed, 12 insertions, 13 deletions
@@ -298,9 +298,7 @@ static void GraphMeterMode_draw(Meter* this, int x, int y, int w) { if (w <= 0) return; - const Machine* host = this->host; GraphData* data = &this->drawData; - if ((size_t)w * 2 > data->nValues) { size_t oldNValues = data->nValues; data->nValues = MAXIMUM(oldNValues + (oldNValues / 2), (size_t)w * 2); @@ -310,6 +308,18 @@ static void GraphMeterMode_draw(Meter* this, int x, int y, int w) { } const size_t nValues = data->nValues; + const Machine* host = this->host; + if (!timercmp(&host->realtime, &(data->time), <)) { + int globalDelay = host->settings->delay; + struct timeval delay = { .tv_sec = globalDelay / 10, .tv_usec = (globalDelay % 10) * 100000L }; + timeradd(&host->realtime, &delay, &(data->time)); + + for (size_t i = 0; i < nValues - 1; i++) + data->values[i] = data->values[i + 1]; + + data->values[nValues - 1] = sumPositiveValues(this->values, this->curItems); + } + const char* const* GraphMeterMode_dots; int GraphMeterMode_pixPerRow; #ifdef HAVE_LIBNCURSESW @@ -323,17 +333,6 @@ static void GraphMeterMode_draw(Meter* this, int x, int y, int w) { GraphMeterMode_pixPerRow = PIXPERROW_ASCII; } - if (!timercmp(&host->realtime, &(data->time), <)) { - int globalDelay = this->host->settings->delay; - struct timeval delay = { .tv_sec = globalDelay / 10, .tv_usec = (globalDelay % 10) * 100000L }; - timeradd(&host->realtime, &delay, &(data->time)); - - for (size_t i = 0; i < nValues - 1; i++) - data->values[i] = data->values[i + 1]; - - data->values[nValues - 1] = sumPositiveValues(this->values, this->curItems); - } - assert(nValues <= SSIZE_MAX); ssize_t i = (ssize_t)nValues - (w * 2); ssize_t k = 0; |