diff options
author | Felipe Oliveira Carvalho <felipekde@gmail.com> | 2014-06-11 03:01:46 -0300 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2014-06-30 03:57:50 -0400 |
commit | 5ed74cfb7c67f79441343ec90548f333dad1729b (patch) | |
tree | 28b0265ba05af45cdaa983462564fbba186f135b /src/nvim/eval.c | |
parent | 45e7814e6aa8aacd8772056863d13770d4e30b48 (diff) | |
download | rneovim-5ed74cfb7c67f79441343ec90548f333dad1729b.tar.gz rneovim-5ed74cfb7c67f79441343ec90548f333dad1729b.tar.bz2 rneovim-5ed74cfb7c67f79441343ec90548f333dad1729b.zip |
Introduce ga_append_via_ptr() and GA_APPEND_VIA_PTR()
Similar to GA_APPEND(). Replaces this pattern:
ga_grow(&ga, 1);
item_type *p = ((item_type *)ga.ga_data) + ga.ga_len;
p->field1 = v1;
p->field2 = v2;
ga.ga_len++;
Diffstat (limited to 'src/nvim/eval.c')
-rw-r--r-- | src/nvim/eval.c | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 4e0f5c9137..15967f484b 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -5290,8 +5290,7 @@ list_join_inner ( len = (int)STRLEN(s); sumlen += len; - ga_grow(join_gap, 1); - p = ((join_T *)join_gap->ga_data) + (join_gap->ga_len++); + p = GA_APPEND_VIA_PTR(join_T, join_gap); if (tofree != NULL || s != numbuf) { p->s = s; p->tofree = tofree; @@ -10218,11 +10217,9 @@ static void f_inputrestore(typval_T *argvars, typval_T *rettv) */ static void f_inputsave(typval_T *argvars, typval_T *rettv) { - /* Add an entry to the stack of typeahead storage. */ - ga_grow(&ga_userinput, 1); - save_typeahead((tasave_T *)(ga_userinput.ga_data) - + ga_userinput.ga_len); - ++ga_userinput.ga_len; + // Add an entry to the stack of typeahead storage. + tasave_T *p = GA_APPEND_VIA_PTR(tasave_T, &ga_userinput); + save_typeahead(p); } /* |