mirror of
https://github.com/vim/vim.git
synced 2025-10-23 08:44:20 -04:00
patch 8.0.0593: duplication of code for adding a list or dict return value
Problem: Duplication of code for adding a list or dict return value. Solution: Add rettv_dict_set() and rettv_list_set(). (Yegappan Lakshmanan)
This commit is contained in:
22
src/dict.c
22
src/dict.c
@@ -59,13 +59,23 @@ rettv_dict_alloc(typval_T *rettv)
|
||||
if (d == NULL)
|
||||
return FAIL;
|
||||
|
||||
rettv->vval.v_dict = d;
|
||||
rettv->v_type = VAR_DICT;
|
||||
rettv_dict_set(rettv, d);
|
||||
rettv->v_lock = 0;
|
||||
++d->dv_refcount;
|
||||
return OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set a dictionary as the return value
|
||||
*/
|
||||
void
|
||||
rettv_dict_set(typval_T *rettv, dict_T *d)
|
||||
{
|
||||
rettv->v_type = VAR_DICT;
|
||||
rettv->vval.v_dict = d;
|
||||
if (d != NULL)
|
||||
++d->dv_refcount;
|
||||
}
|
||||
|
||||
/*
|
||||
* Free a Dictionary, including all non-container items it contains.
|
||||
* Ignores the reference count.
|
||||
@@ -646,11 +656,7 @@ failret:
|
||||
|
||||
*arg = skipwhite(*arg + 1);
|
||||
if (evaluate)
|
||||
{
|
||||
rettv->v_type = VAR_DICT;
|
||||
rettv->vval.v_dict = d;
|
||||
++d->dv_refcount;
|
||||
}
|
||||
rettv_dict_set(rettv, d);
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user