Skip to content

Commit

Permalink
Optimize indent calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
cgzones authored and BenBE committed Aug 4, 2022
1 parent 2b2420d commit 584b487
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions Process.c
Original file line number Diff line number Diff line change
Expand Up @@ -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, " ");
Expand Down

0 comments on commit 584b487

Please sign in to comment.