]> Savannah Git Hosting - gnulib.git/commitdiff
dfa: Simplify a building state
authorNorihiro Tanaka <noritnk@kcn.ne.jp>
Mon, 22 Oct 2018 15:02:16 +0000 (00:02 +0900)
committerJim Meyering <meyering@fb.com>
Sat, 27 Oct 2018 19:48:47 +0000 (12:48 -0700)
dfa.c (build_state): Simplify a building state.

lib/dfa.c

index f8f8aa23e15d8463c3a36cdc6fd1dc06b61c44d9..ad2716bc710210138027ed46cc764e8234437ca4 100644 (file)
--- a/lib/dfa.c
+++ b/lib/dfa.c
@@ -3112,22 +3112,18 @@ build_state (state_num s, struct dfa *d, unsigned char uc)
       /* Find out if the new state will want any context information,
          by calculating possible contexts that the group can match,
          and separate contexts that the new state wants to know.  */
-      int possible_contexts = charclass_context (d, &label);
       int separate_contexts = state_separate_contexts (d, &group);
 
       /* Find the state(s) corresponding to the union of the follows.  */
-      if (possible_contexts & ~separate_contexts)
-        state = state_index (d, &group, separate_contexts ^ CTX_ANY);
-      else
-        state = -1;
-      if (separate_contexts & possible_contexts & CTX_NEWLINE)
-        state_newline = state_index (d, &group, CTX_NEWLINE);
-      else
-        state_newline = state;
-      if (separate_contexts & possible_contexts & CTX_LETTER)
-        state_letter = state_index (d, &group, CTX_LETTER);
+      if (d->syntax.sbit[uc] & separate_contexts & CTX_NEWLINE)
+        state = state_index (d, &group, CTX_NEWLINE);
+      else if (d->syntax.sbit[uc] & separate_contexts & CTX_LETTER)
+        state = state_index (d, &group, CTX_LETTER);
       else
-        state_letter = state;
+        state = state_index (d, &group, separate_contexts ^ CTX_ANY);
+
+      state_newline = state;
+      state_letter = state;
 
       /* Reallocate now, to reallocate any newline transition properly.  */
       realloc_trans_if_necessary (d);