nano

nano with my custom patches
git clone git://bsandro.tech/nano
Log | Files | Refs | README | LICENSE

commit 0404474ec24be4b3e2c8f56c4f304541b6253142
parent a80ade38d79eebc55af82c21ac885d0c7ac23f71
Author: David Lawrence Ramsey <pooka109@gmail.com>
Date:   Fri, 24 Feb 2017 14:44:58 -0600

tweaks: stop converting text once we overshoot span columns

Since we only need span columns of the string, stop scanning the string
as soon as we have that many columns, instead of scanning the string all
the way to the end.  This speeds up the conversion of very long lines.

Diffstat:
Msrc/winio.c | 6++++--
1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/winio.c b/src/winio.c @@ -1807,9 +1807,11 @@ char *display_string(const char *buf, size_t start_col, size_t span, /* The string we return. */ size_t index; /* Current position in converted. */ + size_t beyond = start_col + span; + /* The column number just beyond the last shown character. */ /* If this is data, make room for the "$" at the end of the line. */ - if (isdata && !ISSET(SOFTWRAP) && strlenpt(buf) > start_col + span) + if (isdata && !ISSET(SOFTWRAP) && strlenpt(buf) > beyond) span--; if (span == 0) @@ -1855,7 +1857,7 @@ char *display_string(const char *buf, size_t start_col, size_t span, #endif } - while (*buf != '\0') { + while (*buf != '\0' && start_col < beyond) { int charlength, charwidth = 1; if (*buf == ' ') {