Mercurial > vim
comparison src/popupwin.c @ 17508:34966be2e856 v8.1.1752
patch 8.1.1752: resizing hashtable is inefficient
commit https://github.com/vim/vim/commit/7b73d7ebf71c9148c90a500116f25ec2314c7273
Author: Bram Moolenaar <Bram@vim.org>
Date: Fri Jul 26 21:26:34 2019 +0200
patch 8.1.1752: resizing hashtable is inefficient
Problem: Resizing hashtable is inefficient.
Solution: Avoid resizing when the final size is predictable.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Fri, 26 Jul 2019 21:30:06 +0200 |
parents | 74b6674b99fd |
children | a5427e35d0fb |
comparison
equal
deleted
inserted
replaced
17507:b64a5a737a7c | 17508:34966be2e856 |
---|---|
2030 if (wp == NULL) | 2030 if (wp == NULL) |
2031 return; // invalid {id} | 2031 return; // invalid {id} |
2032 top_extra = popup_top_extra(wp); | 2032 top_extra = popup_top_extra(wp); |
2033 left_extra = wp->w_popup_border[3] + wp->w_popup_padding[3]; | 2033 left_extra = wp->w_popup_border[3] + wp->w_popup_padding[3]; |
2034 | 2034 |
2035 // we know how much space we need, avoid resizing halfway | |
2035 dict = rettv->vval.v_dict; | 2036 dict = rettv->vval.v_dict; |
2037 hash_lock_size(&dict->dv_hashtab, 11); | |
2036 | 2038 |
2037 dict_add_number(dict, "line", wp->w_winrow + 1); | 2039 dict_add_number(dict, "line", wp->w_winrow + 1); |
2038 dict_add_number(dict, "col", wp->w_wincol + 1); | 2040 dict_add_number(dict, "col", wp->w_wincol + 1); |
2039 dict_add_number(dict, "width", wp->w_width + left_extra | 2041 dict_add_number(dict, "width", wp->w_width + left_extra |
2040 + wp->w_popup_border[1] + wp->w_popup_padding[1]); | 2042 + wp->w_popup_border[1] + wp->w_popup_padding[1]); |
2048 | 2050 |
2049 dict_add_number(dict, "scrollbar", wp->w_has_scrollbar); | 2051 dict_add_number(dict, "scrollbar", wp->w_has_scrollbar); |
2050 dict_add_number(dict, "firstline", wp->w_topline); | 2052 dict_add_number(dict, "firstline", wp->w_topline); |
2051 dict_add_number(dict, "visible", | 2053 dict_add_number(dict, "visible", |
2052 win_valid(wp) && (wp->w_popup_flags & POPF_HIDDEN) == 0); | 2054 win_valid(wp) && (wp->w_popup_flags & POPF_HIDDEN) == 0); |
2055 | |
2056 hash_unlock(&dict->dv_hashtab); | |
2053 } | 2057 } |
2054 } | 2058 } |
2055 /* | 2059 /* |
2056 * popup_locate({row}, {col}) | 2060 * popup_locate({row}, {col}) |
2057 */ | 2061 */ |