1
0
forked from aniani/vim

patch 8.2.0182: min() and max() materialize a range() list

Problem:    Min() and max() materialize a range() list.
Solution:   Compute the result without materializing the list. (#5541)
This commit is contained in:
Bram Moolenaar
2020-01-30 16:40:10 +01:00
parent 21109272f5
commit 9f2d020d39
2 changed files with 24 additions and 12 deletions

View File

@@ -4881,9 +4881,18 @@ max_min(typval_T *argvars, typval_T *rettv, int domax)
listitem_T *li;
l = argvars[0].vval.v_list;
if (l != NULL)
if (l != NULL && l->lv_len > 0)
{
if (l->lv_first == &range_list_item)
{
if ((l->lv_u.nonmat.lv_stride > 0) ^ domax)
n = l->lv_u.nonmat.lv_start;
else
n = l->lv_u.nonmat.lv_start + (l->lv_len - 1)
* l->lv_u.nonmat.lv_stride;
}
else
{
range_list_materialize(l);
li = l->lv_first;
if (li != NULL)
{
@@ -4900,6 +4909,7 @@ max_min(typval_T *argvars, typval_T *rettv, int domax)
}
}
}
}
else if (argvars[0].v_type == VAR_DICT)
{
dict_T *d;

View File

@@ -742,6 +742,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
182,
/**/
181,
/**/