From d04962f7883e4cd5d61d06fb11fdde217f7afd79 Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Sun, 24 Feb 2019 20:54:37 +0100 Subject: [PATCH] style: eliminate useless indirection * src/relation.h, src/relation.c (relation_digraph): Don't take the biteetv as a pointer, it is already a pointer (as it's an array). --- src/ielr.c | 4 ++-- src/lalr.c | 4 ++-- src/relation.c | 6 +++--- src/relation.h | 8 +++++--- 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/ielr.c b/src/ielr.c index a1f146b9..e0f53c21 100644 --- a/src/ielr.c +++ b/src/ielr.c @@ -244,7 +244,7 @@ ielr_compute_follow_kernel_items (bitset ritem_sees_lookahead_set, && bitset_test (ritem_sees_lookahead_set, items[j])) bitset_set ((*follow_kernel_itemsp)[i], j); } - relation_digraph (internal_follow_edges, ngotos, follow_kernel_itemsp); + relation_digraph (internal_follow_edges, ngotos, *follow_kernel_itemsp); if (trace_flag & trace_ielr) { @@ -300,7 +300,7 @@ ielr_compute_always_follows (goto_number ***edgesp, } free (edge_array); } - relation_digraph (*edgesp, ngotos, always_followsp); + relation_digraph (*edgesp, ngotos, *always_followsp); if (trace_flag & trace_ielr) { diff --git a/src/lalr.c b/src/lalr.c index 4e2b255c..fd239dc3 100644 --- a/src/lalr.c +++ b/src/lalr.c @@ -193,7 +193,7 @@ initialize_goto_follows (void) } } - relation_digraph (reads, ngotos, &goto_follows); + relation_digraph (reads, ngotos, goto_follows); for (goto_number i = 0; i < ngotos; ++i) free (reads[i]); @@ -312,7 +312,7 @@ follows_print (FILE* out) static void compute_follows (void) { - relation_digraph (includes, ngotos, &goto_follows); + relation_digraph (includes, ngotos, goto_follows); if (trace_flag & trace_sets) follows_print (stderr); for (goto_number i = 0; i < ngotos; ++i) diff --git a/src/relation.c b/src/relation.c index 57c14292..0e9db9d8 100644 --- a/src/relation.c +++ b/src/relation.c @@ -99,7 +99,7 @@ traverse (relation_node i) void -relation_digraph (relation r, relation_node size, bitsetv *function) +relation_digraph (relation r, relation_node size, bitsetv function) { infinity = size + 2; indexes = xcalloc (size + 1, sizeof *indexes); @@ -107,7 +107,7 @@ relation_digraph (relation r, relation_node size, bitsetv *function) top = 0; R = r; - F = *function; + F = function; for (relation_node i = 0; i < size; i++) if (indexes[i] == 0 && R[i]) @@ -116,7 +116,7 @@ relation_digraph (relation r, relation_node size, bitsetv *function) free (indexes); free (vertices); - *function = F; + function = F; } diff --git a/src/relation.h b/src/relation.h index 0edf59e1..e90c052f 100644 --- a/src/relation.h +++ b/src/relation.h @@ -42,9 +42,11 @@ void relation_print (relation r, size_t size, /* Compute the transitive closure of the FUNCTION on the relation R with SIZE vertices. - If R (NODE-1, NODE-2) then on exit FUNCTION[NODE - 1] was extended - (unioned) with FUNCTION[NODE - 2]. */ -void relation_digraph (relation r, relation_node size, bitsetv *function); + If R (NODE1, NODE2) then on exit FUNCTION[NODE1] was extended + (unioned) with FUNCTION[NODE2]. + + FUNCTION is in-out, R is read only. */ +void relation_digraph (const relation r, relation_node size, bitsetv function); /* Destructively transpose *R_ARG, of size SIZE. */ void relation_transpose (relation *R_arg, relation_node size);