From 5283acdcf360f41ef2e597b8def1aaf479e981d3 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Tue, 14 Mar 2017 21:11:51 +0100 Subject: [PATCH] tweaks: trim a displayable string in a more efficient manner Instead of redetermining the entire span of the converted string, simply move one character left, and then bite it off to make place for the trailing $. --- src/winio.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/winio.c b/src/winio.c index 73fdcddf..1e6cc298 100644 --- a/src/winio.c +++ b/src/winio.c @@ -1925,16 +1925,12 @@ char *display_string(const char *buf, size_t start_col, size_t span, buf += charlength + 7; } - /* Null-terminate converted. */ - converted[index] = '\0'; - /* If there is more text than can be shown, make room for the $. */ if (*buf != '\0' && isdata && !ISSET(SOFTWRAP)) - span--; + index = move_mbleft(converted, index); - /* Make sure converted takes up no more than span columns. */ - index = actual_x(converted, span); - null_at(&converted, index); + /* Null-terminate the converted string. */ + converted[index] = '\0'; return converted; }