Subject: [PATCH] dfa: simplify building intial state
From: Norihiro Tanaka <[email-masked]>
To: [email-masked]
Date: Tue, 27 May 2014 08:58:48 +0900
List-Id: <debbugs-submit.debbugs.gnu.org>

I see that initialization isn't needed in build_state_zero().  So remove
it and simplify.
From 6eb06035f4acd7adf6d3fe166471740bd633f6dd Mon Sep 17 00:00:00 2001
From: Norihiro Tanaka <[email-masked]>
Date: Sat, 24 May 2014 09:26:31 +0900
Subject: [PATCH] dfa: simplify building intial state

Initialization of members of struct dfa isn't needed in
build_state_zero().  So remove them, and simplify.

* src/dfa.c (build_state_zero): Remove it.
(dfaexec): Call realloc_trans_if_necessary and build_state directly.
---
 src/dfa.c | 21 ++++-----------------
 1 file changed, 4 insertions(+), 17 deletions(-)

diff --git a/src/dfa.c b/src/dfa.c
index 70dc046..c25322d 100644
--- a/src/dfa.c
+++ b/src/dfa.c
@@ -2896,22 +2896,6 @@ build_state (state_num s, struct dfa *d)
     d->trans[s] = trans;
 }
 
-static void
-build_state_zero (struct dfa *d)
-{
-  /* Initial size of the transition tables; must be positive.  */
-  int initial_tab_size = 1;
-
-  d->tralloc = 0;
-  d->trcount = 0;
-  d->trans = NULL;
-  d->fails = NULL;
-  d->success = NULL;
-  d->newlines = NULL;
-  realloc_trans_if_necessary (d, initial_tab_size);
-  build_state (0, d);
-}
-
 /* Multibyte character handling sub-routines for dfaexec.  */
 
 /* Return values of transit_state_singlebyte, and
@@ -3275,7 +3259,10 @@ dfaexec (struct dfa *d, char const *begin, char *end,
   size_t nlcount = 0;
 
   if (!d->tralloc)
-    build_state_zero (d);
+    {
+      realloc_trans_if_necessary (d, 0);
+      build_state (0, d);
+    }
 
   s = s1 = 0;
   p = mbp = (unsigned char const *) begin;
-- 
1.9.3