commit 355a07bbce710181af6d775a03a621543534123d
parent 0404474ec24be4b3e2c8f56c4f304541b6253142
Author: Benno Schulenberg <bensberg@justemail.net>
Date: Tue, 28 Feb 2017 16:53:51 +0100
tweaks: don't optimize for the wrong case
Running strlenpt() on a string that takes up more than 80 columns
(the width of an average terminal) takes /more/ time than simply
converting an extra character (the one that will be overwritten
by the "$" at the edge of the terminal). So... just convert one
more character than necessary when the line is overlong. In the
most common case, however, the line will fit fully onscreen, and
we save a whole call of strlenpt().
Diffstat:
1 file changed, 0 insertions(+), 7 deletions(-)
diff --git a/src/winio.c b/src/winio.c
@@ -1810,13 +1810,6 @@ char *display_string(const char *buf, size_t start_col, size_t span,
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) > beyond)
- span--;
-
- if (span == 0)
- return mallocstrcpy(NULL, "");
-
start_index = actual_x(buf, start_col);
column = strnlenpt(buf, start_index);