nano

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

commit f1d214c0ef0ec781bae87544851b9d53893d6df5
parent 1d3f3a6e25bad4ef7ca45122f76a29f2937bbaf0
Author: David Lawrence Ramsey <pooka109@gmail.com>
Date:   Mon, 20 Feb 2017 21:07:35 -0600

tweaks: slightly optimize an allocation in display_string()

Instead of allocating enough space to convert the entire passed string,
just allocate space for converting the part that will be converted --
that is: starting from start_index.  This still allocates far too much
(if the passed string is very long and its tail part won't fit on the
screen), but it's better than before.

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

diff --git a/src/winio.c b/src/winio.c @@ -1823,15 +1823,15 @@ char *display_string(const char *buf, size_t start_col, size_t span, assert(column <= start_col); - /* Allocate enough space to hold the entire converted buffer. */ - converted = charalloc(strlen(buf) * (mb_cur_max() + tabsize) + 1); - index = 0; #ifdef USING_OLD_NCURSES seen_wide = FALSE; #endif buf += start_index; + /* Allocate enough space for converting the relevant part of the line. */ + converted = charalloc(strlen(buf) * (mb_cur_max() + tabsize) + 1); + /* If the first character starts before the left edge, or would be * overwritten by a "$" token, then show spaces instead. */ if (*buf != '\0' && *buf != '\t' && (column < start_col ||