summaryrefslogtreecommitdiffstats
path: root/Meter.c
diff options
context:
space:
mode:
authorExplorer09 <explorer09@gmail.com>2023-10-10 20:21:33 +0800
committerBenBE <BenBE@geshi.org>2023-10-10 21:57:39 +0200
commit1a9ae38b5b8454a32863aa24bf2546be54f4b558 (patch)
treec6a296b301a66c879a037218d1411d0a73cac71c /Meter.c
parent9c3e1d4e6422e391b52138ea9ea78db32dc48668 (diff)
GraphMeterMode_draw() code cleanup
* Rework the logic of computing `i` (initial index of graph data records) slightly and remove unreachable code. * Rename k to `col` and change its data type from ssize_t back to int. Signed-off-by: Kang-Che Sung <explorer09@gmail.com>
Diffstat (limited to 'Meter.c')
-rw-r--r--Meter.c12
1 files changed, 3 insertions, 9 deletions
diff --git a/Meter.c b/Meter.c
index e98cc519..460b2925 100644
--- a/Meter.c
+++ b/Meter.c
@@ -333,14 +333,8 @@ static void GraphMeterMode_draw(Meter* this, int x, int y, int w) {
GraphMeterMode_pixPerRow = PIXPERROW_ASCII;
}
- assert(nValues <= SSIZE_MAX);
- ssize_t i = (ssize_t)nValues - (w * 2);
- ssize_t k = 0;
- if (i < 0) {
- k = -i / 2;
- i = 0;
- }
- for (; i < (ssize_t)nValues - 1; i += 2, k++) {
+ size_t i = nValues - (size_t)w * 2;
+ for (int col = 0; i < nValues - 1; i += 2, col++) {
int pix = GraphMeterMode_pixPerRow * GRAPH_HEIGHT;
if (this->total < 1)
this->total = 1;
@@ -353,7 +347,7 @@ static void GraphMeterMode_draw(Meter* this, int x, int y, int w) {
int line2 = CLAMP(v2 - (GraphMeterMode_pixPerRow * (GRAPH_HEIGHT - 1 - line)), 0, GraphMeterMode_pixPerRow);
attrset(CRT_colors[colorIdx]);
- mvaddstr(y + line, x + k, GraphMeterMode_dots[line1 * (GraphMeterMode_pixPerRow + 1) + line2]);
+ mvaddstr(y + line, x + col, GraphMeterMode_dots[line1 * (GraphMeterMode_pixPerRow + 1) + line2]);
colorIdx = GRAPH_2;
}
}

© 2014-2024 Faster IT GmbH | imprint | privacy policy