Commit f1d214c0 authored by David Lawrence Ramsey's avatar David Lawrence Ramsey Committed by Benno Schulenberg
Browse files

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.
No related merge requests found
Showing with 3 additions and 3 deletions
+3 -3
......@@ -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 ||
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment