diff 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
line wrap: on
line diff
--- a/src/popupwin.c
+++ b/src/popupwin.c
@@ -2032,7 +2032,9 @@ f_popup_getpos(typval_T *argvars, typval
 	top_extra = popup_top_extra(wp);
 	left_extra = wp->w_popup_border[3] + wp->w_popup_padding[3];
 
+	// we know how much space we need, avoid resizing halfway
 	dict = rettv->vval.v_dict;
+	hash_lock_size(&dict->dv_hashtab, 11);
 
 	dict_add_number(dict, "line", wp->w_winrow + 1);
 	dict_add_number(dict, "col", wp->w_wincol + 1);
@@ -2050,6 +2052,8 @@ f_popup_getpos(typval_T *argvars, typval
 	dict_add_number(dict, "firstline", wp->w_topline);
 	dict_add_number(dict, "visible",
 		      win_valid(wp) && (wp->w_popup_flags & POPF_HIDDEN) == 0);
+
+	hash_unlock(&dict->dv_hashtab);
     }
 }
 /*