summaryrefslogtreecommitdiffstats
path: root/generic/regc_nfa.c
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2013-03-06 16:27:38 (GMT)
committerdgp <dgp@users.sourceforge.net>2013-03-06 16:27:38 (GMT)
commitfcab8a84a734d1b46afcc12cd5b6416b0b37669c (patch)
tree5c76a792a99cc153c0abdbbe8c9ce647ade02996 /generic/regc_nfa.c
parentd6374c239eef894ece7e7472ada26b15b0abe33e (diff)
downloadtcl-fcab8a84a734d1b46afcc12cd5b6416b0b37669c.zip
tcl-fcab8a84a734d1b46afcc12cd5b6416b0b37669c.tar.gz
tcl-fcab8a84a734d1b46afcc12cd5b6416b0b37669c.tar.bz2
New routine hasnonemptyout() for minor improvement to new fixempties().
Diffstat (limited to 'generic/regc_nfa.c')
-rw-r--r--generic/regc_nfa.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/generic/regc_nfa.c b/generic/regc_nfa.c
index 5857372..0d44fb0 100644
--- a/generic/regc_nfa.c
+++ b/generic/regc_nfa.c
@@ -497,6 +497,22 @@ freearc(
}
/*
+ - hasnonemptyout - Does state have a non-EMPTY out arc?
+ ^ static int hasnonemptyout(struct state *);
+ */
+static int
+hasnonemptyout(s)
+struct state *s;
+{
+ struct arc *a;
+
+ for (a = s->outs; a != NULL; a = a->outchain)
+ if (a->type != EMPTY)
+ return 1;
+ return 0;
+}
+
+/*
- nonemptyouts - count non-EMPTY out arcs of a state
^ static int nonemptyouts(struct state *);
*/
@@ -1388,7 +1404,7 @@ fixempties(
* forward to it, not pull them back to s; and (2) we can optimize
* away the push-forward, per comment above. So do nothing.
*/
- if (s2->flag || nonemptyouts(s2) > 0)
+ if (s2->flag || hasnonemptyout(s2))
replaceempty(nfa, s, s2);
/* Reset the tmp fields as we walk back */