diff options
author | ZyX <kp-pav@yandex.ru> | 2017-12-15 11:40:27 +0300 |
---|---|---|
committer | ZyX <kp-pav@yandex.ru> | 2017-12-16 01:48:20 +0300 |
commit | 91d3efa35a26f6c5e58850413ccbb350cb8e7b37 (patch) | |
tree | e79db7b2df9b6d5c23960f6d3431e966e35c2929 /src/nvim/eval/encode.c | |
parent | fb07391ce46b8bff90ef7ef073b75919a307e64c (diff) | |
download | rneovim-91d3efa35a26f6c5e58850413ccbb350cb8e7b37.tar.gz rneovim-91d3efa35a26f6c5e58850413ccbb350cb8e7b37.tar.bz2 rneovim-91d3efa35a26f6c5e58850413ccbb350cb8e7b37.zip |
eval/encode: Avoid unnecessary tv_list_idx_of_item() calls
Diffstat (limited to 'src/nvim/eval/encode.c')
-rw-r--r-- | src/nvim/eval/encode.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/nvim/eval/encode.c b/src/nvim/eval/encode.c index 39897aa9ab..b7af102681 100644 --- a/src/nvim/eval/encode.c +++ b/src/nvim/eval/encode.c @@ -136,13 +136,18 @@ static int conv_error(const char *const msg, const MPConvStack *const mpstack, } case kMPConvPairs: case kMPConvList: { + const int idx = (v.data.l.li == tv_list_first(v.data.l.list) + ? 0 + : (v.data.l.li == NULL + ? tv_list_len(v.data.l.list) - 1 + : (int)tv_list_idx_of_item( + v.data.l.list, + TV_LIST_ITEM_PREV(v.data.l.list, + v.data.l.li)))); const listitem_T *const li = (v.data.l.li == NULL ? tv_list_last(v.data.l.list) : TV_LIST_ITEM_PREV(v.data.l.list, v.data.l.li)); - int idx = (li == NULL - ? 0 - : (int)tv_list_idx_of_item(v.data.l.list, li)); if (v.type == kMPConvList || li == NULL || (TV_LIST_ITEM_TV(li)->v_type != VAR_LIST |