aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMosder <xmosder12@gmail.com>2026-07-23 20:14:31 +0200
committerMosder <xmosder12@gmail.com>2026-07-23 20:14:31 +0200
commit682f9fc8288fdd01de1d88af87495d9e43f56b06 (patch)
tree3a1aa4416e45f134d38f83d4ea2285f1972f9391
parent4add8c9c34c48f01de58b3b41e79a768063f7acf (diff)
refactor: refactored GCC statment expression into an inline function
-rw-r--r--analyzer/render.h19
1 files changed, 8 insertions, 11 deletions
diff --git a/analyzer/render.h b/analyzer/render.h
index 3604bde..911ca76 100644
--- a/analyzer/render.h
+++ b/analyzer/render.h
@@ -38,17 +38,14 @@ static const ColumnInfo columns[] = {
{"Saturation", 13, COLOR_GREEN},
{"Splinters", 9, COLOR_BLUE},
};
-
-// clang-format off
-#define SUM_COL_WIDTHS ({ \
- size_t sum = 0; \
- for (size_t i = 0; i < ARR_LEN(columns); i++) \
- sum += columns[i].width; \
- sum; \
-})
-// clang-format on
-
-#define TABLE_LINE_WIDTH (TABLE_LINE_START_WIDTH + SUM_COL_WIDTHS + (ARR_LEN(columns) - 1) * TABLE_LINE_SEPARATOR_WIDTH + TABLE_LINE_END_WIDTH)
+static const inline size_t sum_col_widths() {
+ size_t sum = 0;
+ for (size_t i = 0; i < ARR_LEN(columns); i++)
+ sum += columns[i].width;
+ return sum;
+}
+
+#define TABLE_LINE_WIDTH (TABLE_LINE_START_WIDTH + sum_col_widths() + (ARR_LEN(columns) - 1) * TABLE_LINE_SEPARATOR_WIDTH + TABLE_LINE_END_WIDTH)
#define TABLE_ITEMS_WIDTH (TABLE_LINE_WIDTH - TABLE_LINE_START_WIDTH - TABLE_LINE_END_WIDTH)