From 45b5ebea9ddf029b3453ab21d20ae41f32c8de97 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Fri, 14 Apr 2017 17:41:59 +0200 Subject: perf: tv_clear(): Cache gettext() result. (#6519) Closes #6437 --- src/nvim/eval/typval.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/nvim/eval/typval.c b/src/nvim/eval/typval.c index 779bb18175..eb6db9547b 100644 --- a/src/nvim/eval/typval.c +++ b/src/nvim/eval/typval.c @@ -1837,9 +1837,12 @@ static inline void _nothing_conv_dict_end(typval_T *const tv, /// @param[in,out] tv Value to free. void tv_clear(typval_T *const tv) { + static char *objname = NULL; // cached because gettext() is slow. #6437 + if (objname == NULL) { + objname = xstrdup(_("tv_clear() argument")); + } if (tv != NULL && tv->v_type != VAR_UNKNOWN) { - const int evn_ret = encode_vim_to_nothing(NULL, tv, - _("tv_clear() argument")); + const int evn_ret = encode_vim_to_nothing(NULL, tv, objname); (void)evn_ret; assert(evn_ret == OK); } -- cgit