patch 8.2.0751: Vim9: performance can be improved
Problem: Vim9: performance can be improved.
Solution: Don't call break. Inline check for list materialize. Make an
inline version of ga_grow().
diff --git a/src/list.c b/src/list.c
index eb76cc6..6242e52 100644
--- a/src/list.c
+++ b/src/list.c
@@ -378,8 +378,8 @@
if (l1 == NULL || l2 == NULL)
return FALSE;
- range_list_materialize(l1);
- range_list_materialize(l2);
+ CHECK_LIST_MATERIALIZE(l1);
+ CHECK_LIST_MATERIALIZE(l2);
for (item1 = l1->lv_first, item2 = l2->lv_first;
item1 != NULL && item2 != NULL;
@@ -411,7 +411,7 @@
if (n < 0 || n >= l->lv_len)
return NULL;
- range_list_materialize(l);
+ CHECK_LIST_MATERIALIZE(l);
// When there is a cached index may start search from there.
if (l->lv_u.mat.lv_idx_item != NULL)
@@ -541,7 +541,7 @@
if (l == NULL)
return -1;
- range_list_materialize(l);
+ CHECK_LIST_MATERIALIZE(l);
idx = 0;
for (li = l->lv_first; li != NULL && li != item; li = li->li_next)
++idx;
@@ -556,7 +556,7 @@
void
list_append(list_T *l, listitem_T *item)
{
- range_list_materialize(l);
+ CHECK_LIST_MATERIALIZE(l);
if (l->lv_u.mat.lv_last == NULL)
{
// empty list
@@ -706,7 +706,7 @@
void
list_insert(list_T *l, listitem_T *ni, listitem_T *item)
{
- range_list_materialize(l);
+ CHECK_LIST_MATERIALIZE(l);
if (item == NULL)
// Append new item at end of list.
list_append(l, ni);
@@ -741,8 +741,8 @@
listitem_T *item;
int todo = l2->lv_len;
- range_list_materialize(l1);
- range_list_materialize(l2);
+ CHECK_LIST_MATERIALIZE(l1);
+ CHECK_LIST_MATERIALIZE(l2);
// We also quit the loop when we have inserted the original item count of
// the list, avoid a hang when we extend a list with itself.
@@ -801,7 +801,7 @@
orig->lv_copyID = copyID;
orig->lv_copylist = copy;
}
- range_list_materialize(orig);
+ CHECK_LIST_MATERIALIZE(orig);
for (item = orig->lv_first; item != NULL && !got_int;
item = item->li_next)
{
@@ -842,7 +842,7 @@
{
listitem_T *ip;
- range_list_materialize(l);
+ CHECK_LIST_MATERIALIZE(l);
// notify watchers
for (ip = item; ip != NULL; ip = ip->li_next)
@@ -877,7 +877,7 @@
return NULL;
ga_init2(&ga, (int)sizeof(char), 80);
ga_append(&ga, '[');
- range_list_materialize(tv->vval.v_list);
+ CHECK_LIST_MATERIALIZE(tv->vval.v_list);
if (list_join(&ga, tv->vval.v_list, (char_u *)", ",
FALSE, restore_copyID, copyID) == FAIL)
{
@@ -915,7 +915,7 @@
char_u *s;
// Stringify each item in the list.
- range_list_materialize(l);
+ CHECK_LIST_MATERIALIZE(l);
for (item = l->lv_first; item != NULL && !got_int; item = item->li_next)
{
s = echo_string_core(&item->li_tv, &tofree, numbuf, copyID,
@@ -1116,7 +1116,7 @@
int ret = OK;
char_u *s;
- range_list_materialize(list);
+ CHECK_LIST_MATERIALIZE(list);
FOR_ALL_LIST_ITEMS(list, li)
{
for (s = tv_get_string(&li->li_tv); *s != NUL; ++s)
@@ -1203,7 +1203,7 @@
if (argvars[1].v_type != VAR_UNKNOWN)
utf8 = (int)tv_get_number_chk(&argvars[1], NULL);
- range_list_materialize(l);
+ CHECK_LIST_MATERIALIZE(l);
ga_init2(&ga, 1, 80);
if (has_mbyte || utf8)
{
@@ -1496,7 +1496,7 @@
TRUE))
goto theend;
rettv_list_set(rettv, l);
- range_list_materialize(l);
+ CHECK_LIST_MATERIALIZE(l);
len = list_len(l);
if (len <= 1)
@@ -1873,7 +1873,7 @@
// set_vim_var_nr() doesn't set the type
set_vim_var_type(VV_KEY, VAR_NUMBER);
- range_list_materialize(l);
+ CHECK_LIST_MATERIALIZE(l);
if (map && l->lv_lock == 0)
l->lv_lock = VAR_LOCKED;
for (li = l->lv_first; li != NULL; li = nli)
@@ -2011,7 +2011,7 @@
if ((l = argvars[0].vval.v_list) != NULL)
{
- range_list_materialize(l);
+ CHECK_LIST_MATERIALIZE(l);
li = l->lv_first;
if (argvars[2].v_type != VAR_UNKNOWN)
{