ref: 220fd4eb0abc25eb923a4f98d34dae3fd63c1b37
parent: f4f0b0dd085ee82bfca2d761caeb07a9a5ba8d2c
author: Arnold D. Robbins <arnold@skeeve.com>
date: Fri Oct 13 06:44:08 EDT 2023
Be smarter about clearing a goto table.
--- a/b.c
+++ b/b.c
@@ -115,6 +115,7 @@
static int entry_cmp(const void *l, const void *r);
static int get_gototab(fa*, int, int);
static int set_gototab(fa*, int, int, int);
+static void clear_gototab(fa*, int);
extern int u8_rune(int *, const uschar *);
static int *
@@ -269,8 +270,7 @@
}
if ((f->posns[2])[1] == f->accept)
f->out[2] = 1;
- for (i = 0; i < f->gototab[2].allocated; i++)
- set_gototab(f, 2, 0, 0); /* f->gototab[2][i] = 0; */
+ clear_gototab(f, 2);
f->curstat = cgoto(f, 2, HAT);
if (anchor) {*f->posns[2] = k-1; /* leave out position 0 */
@@ -668,6 +668,13 @@
return val; /* not used anywhere at the moment */
}
+static void clear_gototab(fa *f, int state)
+{+ memset(f->gototab[state].entries, 0,
+ f->gototab[state].allocated * sizeof(gtte));
+ f->gototab[state].inuse = 0;
+}
+
int match(fa *f, const char *p0) /* shortest match ? */
{int s, ns;
@@ -1533,8 +1540,7 @@
/* add tmpset to current set of states */
++(f->curstat);
resize_state(f, f->curstat);
- for (i = 0; i < NCHARS; i++)
- set_gototab(f, f->curstat, 0, 0);
+ clear_gototab(f, f->curstat);
xfree(f->posns[f->curstat]);
p = intalloc(setcnt + 1, __func__);
--
⑨