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:
@@ -4881,9 +4881,18 @@ max_min(typval_T *argvars, typval_T *rettv, int domax)
|
|||||||
listitem_T *li;
|
listitem_T *li;
|
||||||
|
|
||||||
l = argvars[0].vval.v_list;
|
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;
|
li = l->lv_first;
|
||||||
if (li != NULL)
|
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)
|
else if (argvars[0].v_type == VAR_DICT)
|
||||||
{
|
{
|
||||||
dict_T *d;
|
dict_T *d;
|
||||||
|
@@ -742,6 +742,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
182,
|
||||||
/**/
|
/**/
|
||||||
181,
|
181,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user