Commit d365ca80 authored by Benno Schulenberg's avatar Benno Schulenberg
Browse files

tweaks: optimize determining the number of columns that a text spans

Give the strlenpt() routine its own implementation, so that it avoids
a needless comparison plus subtraction in the inner loop.
parent f1d214c0
No related merge requests found
Showing with 7 additions and 3 deletions
+7 -3
......@@ -520,11 +520,15 @@ size_t strnlenpt(const char *text, size_t maxlen)
return width;
}
/* A strlen() with tabs and multicolumn characters factored in:
* how many columns wide is text? */
/* Return the number of columns that the given text occupies. */
size_t strlenpt(const char *text)
{
return strnlenpt(text, (size_t)-1);
size_t span = 0;
while (*text != '\0')
text += parse_mbchar(text, NULL, &span);
return span;
}
/* Append a new magicline to filebot. */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment