Mercurial > gnulib
changeset 39958:a18e1269e17d
dfa: Simplify a building state
dfa.c (build_state): Simplify a building state.
author | Norihiro Tanaka <noritnk@kcn.ne.jp> |
---|---|
date | Tue, 23 Oct 2018 00:02:16 +0900 |
parents | 6d6c0b94693c |
children | 2dc9b14f6416 |
files | lib/dfa.c |
diffstat | 1 files changed, 8 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/lib/dfa.c Tue Oct 23 00:01:08 2018 +0900 +++ b/lib/dfa.c Tue Oct 23 00:02:16 2018 +0900 @@ -3112,22 +3112,18 @@ /* 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); + 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 = -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); - 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);