mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
refactor: remove redundant copy in statuscolumn items
Immediately write to buf_tmp instead of to another temporary buffer that is later copied to buf_tmp. Misc cleanup.
This commit is contained in:
parent
fc6477002c
commit
114197517f
@ -1635,18 +1635,16 @@ int build_stl_str_hl(win_T *wp, char *out, size_t outlen, char *fmt, OptIndex op
|
|||||||
if (stcp == NULL) {
|
if (stcp == NULL) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
bool fold = opt == STL_FOLDCOL;
|
int fdc = opt == STL_FOLDCOL ? compute_foldcolumn(wp, 0) : 0;
|
||||||
int fdc = fold ? compute_foldcolumn(wp, 0) : 0;
|
int width = opt == STL_FOLDCOL ? fdc > 0 : wp->w_scwidth;
|
||||||
int width = fold ? fdc > 0 : wp->w_scwidth;
|
|
||||||
|
|
||||||
if (width <= 0) {
|
if (width <= 0) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
foldsignitem = curitem;
|
foldsignitem = curitem;
|
||||||
|
|
||||||
char *p = NULL;
|
if (fdc > 0) {
|
||||||
if (fold) {
|
schar_T fold_buf[9];
|
||||||
schar_T fold_buf[10];
|
|
||||||
fill_foldcolumn(wp, stcp->foldinfo, (linenr_T)get_vim_var_nr(VV_LNUM),
|
fill_foldcolumn(wp, stcp->foldinfo, (linenr_T)get_vim_var_nr(VV_LNUM),
|
||||||
0, fdc, NULL, fold_buf);
|
0, fdc, NULL, fold_buf);
|
||||||
stl_items[curitem].minwid = -((stcp->use_cul ? HLF_CLF : HLF_FC) + 1);
|
stl_items[curitem].minwid = -((stcp->use_cul ? HLF_CLF : HLF_FC) + 1);
|
||||||
@ -1654,31 +1652,26 @@ int build_stl_str_hl(win_T *wp, char *out, size_t outlen, char *fmt, OptIndex op
|
|||||||
// TODO(bfredl): this is very backwards. we must support schar_T
|
// TODO(bfredl): this is very backwards. we must support schar_T
|
||||||
// being used directly in 'statuscolumn'
|
// being used directly in 'statuscolumn'
|
||||||
for (int i = 0; i < fdc; i++) {
|
for (int i = 0; i < fdc; i++) {
|
||||||
buflen += schar_get(out_p + buflen, fold_buf[i]);
|
buflen += schar_get(buf_tmp + buflen, fold_buf[i]);
|
||||||
}
|
}
|
||||||
p = out_p;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
char buf[SIGN_WIDTH * MAX_SCHAR_SIZE];
|
size_t signlen = 0;
|
||||||
size_t buflen = 0;
|
|
||||||
varnumber_T virtnum = get_vim_var_nr(VV_VIRTNUM);
|
|
||||||
for (int i = 0; i < width; i++) {
|
for (int i = 0; i < width; i++) {
|
||||||
if (!fold) {
|
stl_items[curitem].start = out_p + signlen;
|
||||||
SignTextAttrs *sattr = virtnum ? NULL : &stcp->sattrs[i];
|
if (fdc == 0) {
|
||||||
p = " ";
|
if (stcp->sattrs[i].text[0] && get_vim_var_nr(VV_VIRTNUM) == 0) {
|
||||||
if (sattr && sattr->text[0]) {
|
SignTextAttrs sattrs = stcp->sattrs[i];
|
||||||
describe_sign_text(buf, sattr->text);
|
signlen += describe_sign_text(buf_tmp + signlen, sattrs.text);
|
||||||
p = buf;
|
stl_items[curitem].minwid = -(stcp->sign_cul_id ? stcp->sign_cul_id : sattrs.hl_id);
|
||||||
|
} else {
|
||||||
|
buf_tmp[signlen++] = ' ';
|
||||||
|
buf_tmp[signlen++] = ' ';
|
||||||
|
buf_tmp[signlen] = NUL;
|
||||||
|
stl_items[curitem].minwid = -((stcp->use_cul ? HLF_CLS : HLF_SC) + 1);
|
||||||
}
|
}
|
||||||
stl_items[curitem].minwid = -(sattr && sattr->text[0]
|
|
||||||
? (stcp->sign_cul_id ? stcp->sign_cul_id : sattr->hl_id)
|
|
||||||
: (stcp->use_cul ? HLF_CLS : HLF_SC) + 1);
|
|
||||||
}
|
}
|
||||||
stl_items[curitem].type = Highlight;
|
stl_items[curitem++].type = Highlight;
|
||||||
stl_items[curitem].start = out_p + buflen;
|
|
||||||
xstrlcpy(buf_tmp + buflen, p, TMPLEN - buflen);
|
|
||||||
buflen += strlen(p);
|
|
||||||
curitem++;
|
|
||||||
}
|
}
|
||||||
str = buf_tmp;
|
str = buf_tmp;
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user