From 584b487306b9219f3767275ba60d0480445871a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20G=C3=B6ttsche?= Date: Tue, 21 Jun 2022 21:11:16 +0200 Subject: Optimize indent calculation --- Process.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/Process.c b/Process.c index 2a4c809d..465c16af 100644 --- a/Process.c +++ b/Process.c @@ -782,19 +782,11 @@ void Process_writeField(const Process* this, RichString* str, ProcessField field } char* buf = buffer; - int maxIndent = 0; - bool lastItem = (this->indent < 0); - int indent = (this->indent < 0 ? -this->indent : this->indent); + const bool lastItem = (this->indent < 0); - for (int i = 0; i < 32; i++) { - if (indent & (1U << i)) { - maxIndent = i + 1; - } - } - - for (int i = 0; i < maxIndent - 1; i++) { + for (int indent = (this->indent < 0 ? -this->indent : this->indent); indent > 1; indent >>= 1) { int written, ret; - if (indent & (1 << i)) { + if (indent & 1) { ret = xSnprintf(buf, n, "%s ", CRT_treeStr[TREE_STR_VERT]); } else { ret = xSnprintf(buf, n, " "); -- cgit v1.2.3