aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/regexp.c
diff options
context:
space:
mode:
authorFelipe Oliveira Carvalho <felipekde@gmail.com>2014-06-11 03:01:46 -0300
committerJustin M. Keyes <justinkz@gmail.com>2014-06-30 03:57:50 -0400
commit5ed74cfb7c67f79441343ec90548f333dad1729b (patch)
tree28b0265ba05af45cdaa983462564fbba186f135b /src/nvim/regexp.c
parent45e7814e6aa8aacd8772056863d13770d4e30b48 (diff)
downloadrneovim-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/regexp.c')
-rw-r--r--src/nvim/regexp.c11
1 files changed, 3 insertions, 8 deletions
diff --git a/src/nvim/regexp.c b/src/nvim/regexp.c
index 29f090c6b7..0ead83e0d4 100644
--- a/src/nvim/regexp.c
+++ b/src/nvim/regexp.c
@@ -4177,7 +4177,6 @@ regmatch (
case BACK:
{
int i;
- backpos_T *bp;
/*
* When we run into BACK we need to check if we don't keep
@@ -4187,17 +4186,13 @@ regmatch (
* The positions are stored in "backpos" and found by the
* current value of "scan", the position in the RE program.
*/
- bp = (backpos_T *)backpos.ga_data;
+ backpos_T *bp = (backpos_T *)backpos.ga_data;
for (i = 0; i < backpos.ga_len; ++i)
if (bp[i].bp_scan == scan)
break;
if (i == backpos.ga_len) {
- /* First time at this BACK, make room to store the pos. */
- ga_grow(&backpos, 1);
- /* get "ga_data" again, it may have changed */
- bp = (backpos_T *)backpos.ga_data;
- bp[i].bp_scan = scan;
- ++backpos.ga_len;
+ backpos_T *p = GA_APPEND_VIA_PTR(backpos_T, &backpos);
+ p->bp_scan = scan;
} else if (reg_save_equal(&bp[i].bp_pos))
/* Still at same position as last time, fail. */
status = RA_NOMATCH;