When using map() for the list, gettext function is called for each items.
For example, vim doesn't handle dynamic gettext, it become faster than using
dynamic gettext.
---
let n = 1000000
let l = []
for i in range(n) | let l += [localtime() % 10] | endfor
let t = reltime()
call map(l, 'v:val + 1')
echo reltimestr(reltime(t))
---
For example, this script mark 0.721670 on latest version.
After applying below's patch, it mark 0.481578.
diff -r cf5d9c1e4c8a src/eval.c
--- a/src/eval.c Fri Apr 17 22:08:16 2015 +0200
+++ b/src/eval.c Sun Apr 19 22:13:38 2015 +0900
@@ -10499,7 +10499,7 @@
dictitem_T *di1;
hashitem_T *hi2;
int todo;
- char *arg_errmsg = N_("extend() argument");
+ char_u *arg_errmsg = _("extend() argument");
todo = (int)d2->dv_hashtab.ht_used;
for (hi2 = d2->dv_hashtab.ht_array; todo > 0; ++hi2)
@@ -10534,8 +10534,8 @@
}
else if (*action == 'f' && HI2DI(hi2) != di1)
{
- if (tv_check_lock(di1->di_tv.v_lock, (char_u *)_(arg_errmsg))
- || var_check_ro(di1->di_flags, (char_u *)_(arg_errmsg)))
+ if (tv_check_lock(di1->di_tv.v_lock, arg_errmsg)
+ || var_check_ro(di1->di_flags, arg_errmsg))
break;
clear_tv(&di1->di_tv);
copy_tv(&HI2DI(hi2)->di_tv, &di1->di_tv);
@@ -10819,21 +10819,21 @@
int rem;
int todo;
char_u *ermsg = (char_u *)(map ? "map()" : "filter()");
- char *arg_errmsg = (map ? N_("map() argument")
- : N_("filter() argument"));
+ char_u *arg_errmsg = (map ? _("map() argument")
+ : _("filter() argument"));
int save_did_emsg;
int idx = 0;
if (argvars[0].v_type == VAR_LIST)
{
if ((l = argvars[0].vval.v_list) == NULL
- || (!map && tv_check_lock(l->lv_lock, (char_u *)_(arg_errmsg))))
+ || (!map && tv_check_lock(l->lv_lock, arg_errmsg)))
return;
}
else if (argvars[0].v_type == VAR_DICT)
{
if ((d = argvars[0].vval.v_dict) == NULL
- || (!map && tv_check_lock(d->dv_lock, (char_u *)_(arg_errmsg))))
+ || (!map && tv_check_lock(d->dv_lock, arg_errmsg)))
return;
}
else
@@ -10873,10 +10873,8 @@
--todo;
di = HI2DI(hi);
if (map &&
- (tv_check_lock(di->di_tv.v_lock,
- (char_u *)_(arg_errmsg))
- || var_check_ro(di->di_flags,
- (char_u *)_(arg_errmsg))))
+ (tv_check_lock(di->di_tv.v_lock, arg_errmsg)
+ || var_check_ro(di->di_flags, arg_errmsg)))
break;
vimvars[VV_KEY].vv_str = vim_strsave(di->di_key);
r = filter_map_one(&di->di_tv, expr, map, &rem);
@@ -10885,10 +10883,8 @@
break;
if (!map && rem)
{
- if (var_check_fixed(di->di_flags,
- (char_u *)_(arg_errmsg))
- || var_check_ro(di->di_flags,
- (char_u *)_(arg_errmsg)))
+ if (var_check_fixed(di->di_flags, arg_errmsg)
+ || var_check_ro(di->di_flags, arg_errmsg))
break;
dictitem_remove(d, di);
}
@@ -10902,8 +10898,7 @@
for (li = l->lv_first; li != NULL; li = nli)
{
- if (map && tv_check_lock(li->li_tv.v_lock,
- (char_u *)_(arg_errmsg)))
+ if (map && tv_check_lock(li->li_tv.v_lock, arg_errmsg))
break;
nli = li->li_next;
vimvars[VV_KEY].vv_nr = idx;
- mattn
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.