From: Kevin McCarthy Date: Wed, 15 Nov 2017 22:53:24 +0000 (-0800) Subject: Remove useless else branch in the $smart_wrap code. (see #3857) X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3b926b821a807e90ff95dd1999e8509a70bb64d1;p=neomutt Remove useless else branch in the $smart_wrap code. (see #3857) Thanks to Vincent Lefèvre for noticing the nested else was redundant, since buf_ptr is already set to "buf + cnt" after the format_line() call. This allows us to merge the inner and outer if statement, resulting in simpler code. --- diff --git a/pager.c b/pager.c index f2c0c1193..c3c3bfeb3 100644 --- a/pager.c +++ b/pager.c @@ -1560,27 +1560,22 @@ static int display_line(FILE *f, LOFF_T *last_pos, struct Line **line_info, /* move the break point only if smart_wrap is set */ if (option(OPT_SMART_WRAP)) { - if (cnt < b_read) + if ((cnt < b_read) && (ch != -1) && !ISHEADER((*line_info)[n].type) && + !ISSPACE(buf[cnt])) { - /* Wrap if the line is not part of the header and buf[cnt] is not whitespace */ - if (ch != -1 && !ISHEADER((*line_info)[n].type) && !ISSPACE(buf[cnt])) - { - buf_ptr = buf + ch; - /* skip trailing blanks */ - while (ch && (buf[ch] == ' ' || buf[ch] == '\t' || buf[ch] == '\r')) - ch--; - /* A very long word with leading spaces causes infinite - * wrapping when MUTT_PAGER_NSKIP is set. A folded header - * with a single long word shouldn't be smartwrapped - * either. So just disable smart_wrap if it would wrap at the - * beginning of the line. */ - if (!ch) - buf_ptr = buf + cnt; - else - cnt = ch + 1; - } + buf_ptr = buf + ch; + /* skip trailing blanks */ + while (ch && (buf[ch] == ' ' || buf[ch] == '\t' || buf[ch] == '\r')) + ch--; + /* A very long word with leading spaces causes infinite + * wrapping when MUTT_PAGER_NSKIP is set. A folded header + * with a single long word shouldn't be smartwrapped + * either. So just disable smart_wrap if it would wrap at the + * beginning of the line. */ + if (!ch) + buf_ptr = buf + cnt; else - buf_ptr = buf + cnt; /* a very long word... */ + cnt = ch + 1; } if (!(flags & MUTT_PAGER_NSKIP)) /* skip leading blanks on the next line too */