Skip to content

Instantly share code, notes, and snippets.

@koron
Created January 12, 2012 13:17
Show Gist options
  • Save koron/1600472 to your computer and use it in GitHub Desktop.
Save koron/1600472 to your computer and use it in GitHub Desktop.
diff -r 2cab0b1a3f29 src/eval.c
--- a/src/eval.c Wed Jan 11 18:57:32 2012 +0900
+++ b/src/eval.c Thu Jan 12 22:16:49 2012 +0900
@@ -6591,17 +6591,32 @@
listitem_T *item;
char_u *s;
+ int count = 0;
+ int sumlen = 0;
+ char_u * (*tostr)(typval_T *, char_u **, char_u *, int);
+
+ tostr = echo_style ? echo_string : tv2string;
+
+ for (item = l->lv_first; item != NULL && !got_int; item = item->li_next)
+ {
+ s = tostr(&item->li_tv, &tofree, numbuf, copyID);
+ if (s != NULL)
+ sumlen = (int)STRLEN(s);
+ vim_free(tofree);
+ line_breakcheck();
+ ++count;
+ }
+
+ sumlen += (int)STRLEN(sep) * (count - 1);
+ ga_grow(gap, sumlen + 1);
+
for (item = l->lv_first; item != NULL && !got_int; item = item->li_next)
{
if (first)
first = FALSE;
else
ga_concat(gap, sep);
-
- if (echo_style)
- s = echo_string(&item->li_tv, &tofree, numbuf, copyID);
- else
- s = tv2string(&item->li_tv, &tofree, numbuf, copyID);
+ s = tostr(&item->li_tv, &tofree, numbuf, copyID);
if (s != NULL)
ga_concat(gap, s);
vim_free(tofree);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment