commit d30ca576b7c64a6425468412592d66e29477df0b
parent ed520c89bc71f69197a9ea4c2609943e23e1be28
Author: Benno Schulenberg <bensberg@telfort.nl>
Date: Thu, 19 Dec 2019 12:07:36 +0100
tweaks: optimize the trimming of trailing whitespace
When justifying a paragraph, always first squeeze() is called on
the text (which at that moment consists of a single long line),
which means that (in its wrappable part) this line contains only
single spaces as word separators (and maybe a double space after
a period). So there is no need to call the general is_blank()
function -- checking for a space is enough.
Diffstat:
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/src/text.c b/src/text.c
@@ -1854,10 +1854,9 @@ void rewrap_paragraph(linestruct **line, char *lead_string, size_t lead_len)
strncpy((*line)->next->data, lead_string, lead_len);
strcpy((*line)->next->data + lead_len, (*line)->data + break_pos);
- /* When requested, snip all trailing blanks. */
+ /* When requested, snip the one or two trailing spaces. */
if (ISSET(TRIM_BLANKS)) {
- while (break_pos > 0 &&
- is_blank_mbchar(&(*line)->data[break_pos - 1]))
+ while (break_pos > 0 && (*line)->data[break_pos - 1] == ' ')
break_pos--;
}