summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Göttsche <cgzones@googlemail.com>2022-06-21 21:11:16 +0200
committerBenBE <BenBE@geshi.org>2022-08-04 19:49:52 +0200
commit584b487306b9219f3767275ba60d0480445871a5 (patch)
tree5614cc2519a3651600c2ac6723deb292aee00204
parent2b2420d0ebd4734b59f5d72ad2d5959af90da261 (diff)
Optimize indent calculation
-rw-r--r--Process.c14
1 files 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, " ");

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