mirror of
https://github.com/neovim/neovim.git
synced 2025-09-18 17:28:23 +00:00
vim-patch:8.0.0593: DRY: setting list/dict return value (#8639)
Problem: Duplication of code for adding a list or dict return value.
Solution: Add rettv_dict_set() and rettv_list_set(). (Yegappan Lakshmanan)
45cf6e910c
This commit is contained in:

committed by
Justin M. Keyes

parent
d088331ea3
commit
70626e6a1e
@@ -1914,10 +1914,8 @@ list_T *tv_list_alloc_ret(typval_T *const ret_tv, const ptrdiff_t len)
|
||||
FUNC_ATTR_NONNULL_ALL
|
||||
{
|
||||
list_T *const l = tv_list_alloc(len);
|
||||
ret_tv->vval.v_list = l;
|
||||
ret_tv->v_type = VAR_LIST;
|
||||
tv_list_set_ret(ret_tv, l);
|
||||
ret_tv->v_lock = VAR_UNLOCKED;
|
||||
tv_list_ref(l);
|
||||
return l;
|
||||
}
|
||||
|
||||
@@ -1930,10 +1928,8 @@ void tv_dict_alloc_ret(typval_T *const ret_tv)
|
||||
FUNC_ATTR_NONNULL_ALL
|
||||
{
|
||||
dict_T *const d = tv_dict_alloc();
|
||||
ret_tv->vval.v_dict = d;
|
||||
ret_tv->v_type = VAR_DICT;
|
||||
tv_dict_set_ret(ret_tv, d);
|
||||
ret_tv->v_lock = VAR_UNLOCKED;
|
||||
d->dv_refcount++;
|
||||
}
|
||||
|
||||
//{{{3 Clear
|
||||
|
Reference in New Issue
Block a user