summaryrefslogtreecommitdiff
path: root/dfa.c
diff options
context:
space:
mode:
authorwlestes <wlestes>2012-02-17 22:22:59 +0000
committerwlestes <wlestes>2012-02-17 22:22:59 +0000
commitd5c9b65dfd42e2487b344532e4d1bda153b840ec (patch)
tree2c62af79e432d069b63553e9080433e2b5193cdf /dfa.c
parente7c6bb731cd0e4f3d50afc56102c9da06ed2a61c (diff)
downloadflex-d5c9b65dfd42e2487b344532e4d1bda153b840ec.tar.gz
speed up things for complex inputs; resolves #2891390
Diffstat (limited to 'dfa.c')
-rw-r--r--dfa.c13
1 files changed, 5 insertions, 8 deletions
diff --git a/dfa.c b/dfa.c
index 8613d75..b8b68eb 100644
--- a/dfa.c
+++ b/dfa.c
@@ -161,7 +161,7 @@ void dump_associated_rules (file, ds)
}
}
- bubble (rule_set, num_associated_rules);
+ qsort (&rule_set [1], num_associated_rules, sizeof (rule_set [1]), intcmp);
fprintf (file, _(" associated rule line numbers:"));
@@ -835,10 +835,8 @@ int snstods (sns, numstates, accset, nacc, hashval, newds_addr)
if (!didsort) {
/* We sort the states in sns so we
* can compare it to oldsns quickly.
- * We use bubble because there probably
- * aren't very many states.
*/
- bubble (sns, numstates);
+ qsort (&sns [1], numstates, sizeof (sns [1]), intcmp);
didsort = 1;
}
@@ -873,7 +871,7 @@ int snstods (sns, numstates, accset, nacc, hashval, newds_addr)
*/
if (!didsort)
- bubble (sns, numstates);
+ qsort (&sns [1], numstates, sizeof (sns [1]), intcmp);
for (i = 1; i <= numstates; ++i)
dss[newds][i] = sns[i];
@@ -893,11 +891,10 @@ int snstods (sns, numstates, accset, nacc, hashval, newds_addr)
else if (reject) {
/* We sort the accepting set in increasing order so the
* disambiguating rule that the first rule listed is considered
- * match in the event of ties will work. We use a bubble
- * sort since the list is probably quite small.
+ * match in the event of ties will work.
*/
- bubble (accset, nacc);
+ qsort (&accset [1], nacc, sizeof (accset [1]), intcmp);
dfaacc[newds].dfaacc_set =
allocate_integer_array (nacc + 1);