From 341776b03b921b7dfd508329b8d891cac08a63af Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Sun, 31 Mar 2019 14:30:44 +0200 Subject: [PATCH] graphviz: move constant computation out of a loop * src/graphviz.c (output_red): here. --- src/graphviz.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/graphviz.c b/src/graphviz.c index 75e4a6e6..4a826cb3 100644 --- a/src/graphviz.c +++ b/src/graphviz.c @@ -159,6 +159,9 @@ output_red (state const *s, reductions const *reds, FILE *fout) bitset no_reduce_set; no_reduce_bitset_init (s, &no_reduce_set); + rule *default_reduction + = yydefact[s->number] ? &rules[yydefact[s->number] - 1] : NULL; + /* Two obstacks are needed: one for the enabled reductions, and one for the disabled reductions, because in the end we want two separate edges, even though in most cases only one will actually @@ -171,11 +174,6 @@ output_red (state const *s, reductions const *reds, FILE *fout) const int source = s->number; for (int j = 0; j < reds->num; ++j) { - rule *default_reduction = - yydefact[s->number] - ? &rules[yydefact[s->number] - 1] - : NULL; - bool defaulted = default_reduction && default_reduction == reds->rules[j]; /* Build the lookahead tokens lists, one for enabled transitions