Now, state indexes for state 0 state 0 are 0 for CTX_NEWLINE context,
D->initstate_notbol for CTX_NONE context and D->min_trcount - 1 for
CTX_LETTER.  The patch uses them instead of calling state_index().
From bb5fc2fa08e9f2b17d147c3649328254deb84166 Mon Sep 17 00:00:00 2001
From: Norihiro Tanaka <nori...@kcn.ne.jp>
Date: Wed, 17 Aug 2016 23:04:15 +0900
Subject: [PATCH] dfa: simplify to find state index for state 0

* src/dfa.c (dfastate): Simplify to find state index for state 0.
---
 src/dfa.c |   15 +++------------
 1 files changed, 3 insertions(+), 12 deletions(-)

diff --git a/src/dfa.c b/src/dfa.c
index b64a176..6848aef 100644
--- a/src/dfa.c
+++ b/src/dfa.c
@@ -2722,18 +2722,9 @@ dfastate (state_num s, struct dfa *d, state_num trans[])
      is to fail miserably.  */
   if (d->searchflag)
     {
-      /* Find the state(s) corresponding to the positions of state 0.  */
-      copy (&d->states[0].elems, &follows);
-      separate_contexts = state_separate_contexts (&follows);
-      state = state_index (d, &follows, separate_contexts ^ CTX_ANY);
-      if (separate_contexts & CTX_NEWLINE)
-        state_newline = state_index (d, &follows, CTX_NEWLINE);
-      else
-        state_newline = state;
-      if (separate_contexts & CTX_LETTER)
-        state_letter = state_index (d, &follows, CTX_LETTER);
-      else
-        state_letter = state;
+      state_newline = 0;
+      state_letter = d->min_trcount - 1;
+      state = d->initstate_notbol;
 
       for (i = 0; i < NOTCHAR; ++i)
         trans[i] = unibyte_word_constituent (i) ? state_letter : state;
-- 
1.7.1

Reply via email to