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 $.master
parent
0d9a734724
commit
5283acdcf3
10
src/winio.c
10
src/winio.c
|
@ -1925,16 +1925,12 @@ char *display_string(const char *buf, size_t start_col, size_t span,
|
||||||
buf += charlength + 7;
|
buf += charlength + 7;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Null-terminate converted. */
|
|
||||||
converted[index] = '\0';
|
|
||||||
|
|
||||||
/* If there is more text than can be shown, make room for the $. */
|
/* If there is more text than can be shown, make room for the $. */
|
||||||
if (*buf != '\0' && isdata && !ISSET(SOFTWRAP))
|
if (*buf != '\0' && isdata && !ISSET(SOFTWRAP))
|
||||||
span--;
|
index = move_mbleft(converted, index);
|
||||||
|
|
||||||
/* Make sure converted takes up no more than span columns. */
|
/* Null-terminate the converted string. */
|
||||||
index = actual_x(converted, span);
|
converted[index] = '\0';
|
||||||
null_at(&converted, index);
|
|
||||||
|
|
||||||
return converted;
|
return converted;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue