From d30ca576b7c64a6425468412592d66e29477df0b Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Thu, 19 Dec 2019 12:07:36 +0100 Subject: [PATCH] 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. --- src/text.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/text.c b/src/text.c index aa5c05c5..548f02ee 100644 --- 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--; }