From c0d60526541a3cf977ae623471ae4a347b492af1 Mon Sep 17 00:00:00 2001 From: bfredl Date: Tue, 23 Aug 2022 09:33:08 +0200 Subject: perf(api): allow to use an arena for return values --- src/nvim/cmdhist.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/nvim/cmdhist.c') diff --git a/src/nvim/cmdhist.c b/src/nvim/cmdhist.c index 13f97ba1e8..b078fc6570 100644 --- a/src/nvim/cmdhist.c +++ b/src/nvim/cmdhist.c @@ -494,7 +494,7 @@ static int del_history_idx(int histype, int idx) } /// "histadd()" function -void f_histadd(typval_T *argvars, typval_T *rettv, FunPtr fptr) +void f_histadd(typval_T *argvars, typval_T *rettv, EvalFuncData fptr) { HistoryType histype; @@ -517,7 +517,7 @@ void f_histadd(typval_T *argvars, typval_T *rettv, FunPtr fptr) } /// "histdel()" function -void f_histdel(typval_T *argvars, typval_T *rettv, FunPtr fptr) +void f_histdel(typval_T *argvars, typval_T *rettv, EvalFuncData fptr) { int n; const char *const str = tv_get_string_chk(&argvars[0]); // NULL on type error @@ -540,7 +540,7 @@ void f_histdel(typval_T *argvars, typval_T *rettv, FunPtr fptr) } /// "histget()" function -void f_histget(typval_T *argvars, typval_T *rettv, FunPtr fptr) +void f_histget(typval_T *argvars, typval_T *rettv, EvalFuncData fptr) { HistoryType type; int idx; @@ -562,7 +562,7 @@ void f_histget(typval_T *argvars, typval_T *rettv, FunPtr fptr) } /// "histnr()" function -void f_histnr(typval_T *argvars, typval_T *rettv, FunPtr fptr) +void f_histnr(typval_T *argvars, typval_T *rettv, EvalFuncData fptr) { const char *const histname = tv_get_string_chk(&argvars[0]); HistoryType i = histname == NULL -- cgit From 608134794d2a039358825396b860a7f432c1a4bd Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 27 Aug 2022 06:50:55 +0800 Subject: vim-patch:9.0.0284: using static buffer for multiple completion functions Problem: Using static buffer for multiple completion functions. Solution: Use one buffer in expand_T. https://github.com/vim/vim/commit/5ff595d9db2d9a33aa10cc9f18f256826226862f --- src/nvim/cmdhist.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/nvim/cmdhist.c') diff --git a/src/nvim/cmdhist.c b/src/nvim/cmdhist.c index b078fc6570..1426054d0b 100644 --- a/src/nvim/cmdhist.c +++ b/src/nvim/cmdhist.c @@ -90,14 +90,14 @@ static char *(history_names[]) = { /// arguments of the ":history command. char *get_history_arg(expand_T *xp, int idx) { - static char_u compl[2] = { NUL, NUL }; - char *short_names = ":=@>?/"; - int short_names_count = (int)STRLEN(short_names); - int history_name_count = ARRAY_SIZE(history_names) - 1; + const char *short_names = ":=@>?/"; + const int short_names_count = (int)STRLEN(short_names); + const int history_name_count = ARRAY_SIZE(history_names) - 1; if (idx < short_names_count) { - compl[0] = (char_u)short_names[idx]; - return (char *)compl; + xp->xp_buf[0] = short_names[idx]; + xp->xp_buf[1] = NUL; + return xp->xp_buf; } if (idx < short_names_count + history_name_count) { return history_names[idx - short_names_count]; -- cgit From 5f92d9b345e11adb73df33dc22a8e656aca73b6c Mon Sep 17 00:00:00 2001 From: bfredl Date: Thu, 1 Sep 2022 09:44:01 +0200 Subject: perf(messages): don't call ui_flush() per message line in various places When msgsep is used, message scrolling is emulated. To make message output fast, inhibit emulated scrolling until the full message text is known --- src/nvim/cmdhist.c | 1 - 1 file changed, 1 deletion(-) (limited to 'src/nvim/cmdhist.c') diff --git a/src/nvim/cmdhist.c b/src/nvim/cmdhist.c index 1426054d0b..2057b0db9e 100644 --- a/src/nvim/cmdhist.c +++ b/src/nvim/cmdhist.c @@ -650,7 +650,6 @@ void ex_history(exarg_T *eap) STRCAT(IObuff, hist[i].hisstr); } msg_outtrans((char *)IObuff); - ui_flush(); } if (i == idx) { break; -- cgit From 49e893f296bca9eef5ff45a3d746c261d055bf10 Mon Sep 17 00:00:00 2001 From: Dundar Göc Date: Fri, 26 Aug 2022 23:11:25 +0200 Subject: refactor: replace char_u with char Work on https://github.com/neovim/neovim/issues/459 --- src/nvim/cmdhist.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'src/nvim/cmdhist.c') diff --git a/src/nvim/cmdhist.c b/src/nvim/cmdhist.c index 2057b0db9e..629c47f24a 100644 --- a/src/nvim/cmdhist.c +++ b/src/nvim/cmdhist.c @@ -201,7 +201,7 @@ static int in_history(int type, char_u *str, int move_to_front, int sep) // For search history, check that the separator character matches as // well. - char_u *p = history[type][i].hisstr; + char_u *p = (char_u *)history[type][i].hisstr; if (STRCMP(str, p) == 0 && (type != HIST_SEARCH || sep == p[STRLEN(p) + 1])) { if (!move_to_front) { @@ -217,7 +217,7 @@ static int in_history(int type, char_u *str, int move_to_front, int sep) if (last_i >= 0) { list_T *const list = history[type][i].additional_elements; - str = history[type][i].hisstr; + str = (char_u *)history[type][i].hisstr; while (i != hisidx[type]) { if (++i >= hislen) { i = 0; @@ -227,7 +227,7 @@ static int in_history(int type, char_u *str, int move_to_front, int sep) } tv_list_unref(list); history[type][i].hisnum = ++hisnum[type]; - history[type][i].hisstr = str; + history[type][i].hisstr = (char *)str; history[type][i].timestamp = os_time(); history[type][i].additional_elements = NULL; return true; @@ -276,7 +276,7 @@ static int last_maptick = -1; // last seen maptick /// @param histype may be one of the HIST_ values. /// @param in_map consider maptick when inside a mapping /// @param sep separator character used (search hist) -void add_to_history(int histype, char_u *new_entry, int in_map, int sep) +void add_to_history(int histype, char *new_entry, int in_map, int sep) { histentry_T *hisptr; @@ -304,7 +304,7 @@ void add_to_history(int histype, char_u *new_entry, int in_map, int sep) } last_maptick = -1; } - if (!in_history(histype, new_entry, true, sep)) { + if (!in_history(histype, (char_u *)new_entry, true, sep)) { if (++hisidx[histype] == hislen) { hisidx[histype] = 0; } @@ -313,10 +313,10 @@ void add_to_history(int histype, char_u *new_entry, int in_map, int sep) // Store the separator after the NUL of the string. size_t len = STRLEN(new_entry); - hisptr->hisstr = vim_strnsave(new_entry, len + 2); + hisptr->hisstr = xstrnsave(new_entry, len + 2); hisptr->timestamp = os_time(); hisptr->additional_elements = NULL; - hisptr->hisstr[len + 1] = (char_u)sep; + hisptr->hisstr[len + 1] = (char)sep; hisptr->hisnum = ++hisnum[histype]; if (histype == HIST_SEARCH && in_map) { @@ -386,7 +386,7 @@ static char_u *get_history_entry(int histype, int idx) { idx = calc_hist_idx(histype, idx); if (idx >= 0) { - return history[histype][idx].hisstr; + return (char_u *)history[histype][idx].hisstr; } else { return (char_u *)""; } @@ -438,7 +438,7 @@ static int del_history_entry(int histype, char_u *str) if (hisptr->hisstr == NULL) { break; } - if (vim_regexec(®match, (char *)hisptr->hisstr, (colnr_T)0)) { + if (vim_regexec(®match, hisptr->hisstr, (colnr_T)0)) { found = true; hist_free_entry(hisptr); } else { @@ -509,7 +509,7 @@ void f_histadd(typval_T *argvars, typval_T *rettv, EvalFuncData fptr) str = tv_get_string_buf(&argvars[1], buf); if (*str != NUL) { init_history(); - add_to_history(histype, (char_u *)str, false, NUL); + add_to_history(histype, (char *)str, false, NUL); rettv->vval.v_number = true; return; } @@ -643,8 +643,8 @@ void ex_history(exarg_T *eap) msg_putchar('\n'); snprintf((char *)IObuff, IOSIZE, "%c%6d ", i == idx ? '>' : ' ', hist[i].hisnum); - if (vim_strsize((char *)hist[i].hisstr) > Columns - 10) { - trunc_string((char *)hist[i].hisstr, (char *)IObuff + STRLEN(IObuff), + if (vim_strsize(hist[i].hisstr) > Columns - 10) { + trunc_string(hist[i].hisstr, (char *)IObuff + STRLEN(IObuff), Columns - 10, IOSIZE - (int)STRLEN(IObuff)); } else { STRCAT(IObuff, hist[i].hisstr); -- cgit From 73207cae611a1efb8cd17139e8228772daeb9866 Mon Sep 17 00:00:00 2001 From: Dundar Göc Date: Fri, 26 Aug 2022 23:11:25 +0200 Subject: refactor: replace char_u with char Work on https://github.com/neovim/neovim/issues/459 --- src/nvim/cmdhist.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/nvim/cmdhist.c') diff --git a/src/nvim/cmdhist.c b/src/nvim/cmdhist.c index 629c47f24a..38353f44b5 100644 --- a/src/nvim/cmdhist.c +++ b/src/nvim/cmdhist.c @@ -382,13 +382,13 @@ static int calc_hist_idx(int histype, int num) /// Get a history entry by its index. /// /// @param histype may be one of the HIST_ values. -static char_u *get_history_entry(int histype, int idx) +static char *get_history_entry(int histype, int idx) { idx = calc_hist_idx(histype, idx); if (idx >= 0) { - return (char_u *)history[histype][idx].hisstr; + return history[histype][idx].hisstr; } else { - return (char_u *)""; + return ""; } } @@ -556,7 +556,7 @@ void f_histget(typval_T *argvars, typval_T *rettv, EvalFuncData fptr) idx = (int)tv_get_number_chk(&argvars[1], NULL); } // -1 on type error - rettv->vval.v_string = (char *)vim_strsave(get_history_entry(type, idx)); + rettv->vval.v_string = xstrdup(get_history_entry(type, idx)); } rettv->v_type = VAR_STRING; } -- cgit From c5322e752e9e568de907f7a1ef733bbfe342140c Mon Sep 17 00:00:00 2001 From: Dundar Göc Date: Fri, 26 Aug 2022 23:11:25 +0200 Subject: refactor: replace char_u with char Work on https://github.com/neovim/neovim/issues/459 --- src/nvim/cmdhist.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/nvim/cmdhist.c') diff --git a/src/nvim/cmdhist.c b/src/nvim/cmdhist.c index 38353f44b5..3747c91c4f 100644 --- a/src/nvim/cmdhist.c +++ b/src/nvim/cmdhist.c @@ -186,7 +186,7 @@ static inline void clear_hist_entry(histentry_T *hisptr) /// If 'move_to_front' is true, matching entry is moved to end of history. /// /// @param move_to_front Move the entry to the front if it exists -static int in_history(int type, char_u *str, int move_to_front, int sep) +static int in_history(int type, char *str, int move_to_front, int sep) { int last_i = -1; @@ -201,8 +201,8 @@ static int in_history(int type, char_u *str, int move_to_front, int sep) // For search history, check that the separator character matches as // well. - char_u *p = (char_u *)history[type][i].hisstr; - if (STRCMP(str, p) == 0 + char *p = history[type][i].hisstr; + if (strcmp(str, p) == 0 && (type != HIST_SEARCH || sep == p[STRLEN(p) + 1])) { if (!move_to_front) { return true; @@ -217,7 +217,7 @@ static int in_history(int type, char_u *str, int move_to_front, int sep) if (last_i >= 0) { list_T *const list = history[type][i].additional_elements; - str = (char_u *)history[type][i].hisstr; + str = history[type][i].hisstr; while (i != hisidx[type]) { if (++i >= hislen) { i = 0; @@ -227,7 +227,7 @@ static int in_history(int type, char_u *str, int move_to_front, int sep) } tv_list_unref(list); history[type][i].hisnum = ++hisnum[type]; - history[type][i].hisstr = (char *)str; + history[type][i].hisstr = str; history[type][i].timestamp = os_time(); history[type][i].additional_elements = NULL; return true; @@ -304,7 +304,7 @@ void add_to_history(int histype, char *new_entry, int in_map, int sep) } last_maptick = -1; } - if (!in_history(histype, (char_u *)new_entry, true, sep)) { + if (!in_history(histype, new_entry, true, sep)) { if (++hisidx[histype] == hislen) { hisidx[histype] = 0; } -- cgit