From ce1903bd7f603924966363e41687f802280399c6 Mon Sep 17 00:00:00 2001
From: "Sven M. Hallberg" <pesco@khjk.org>
Date: Tue, 11 Feb 2020 19:53:39 +0100
Subject: [PATCH] while here, get rid of an unneeded allocation

---
 src/backends/lalr.c | 14 ++------------
 1 file changed, 2 insertions(+), 12 deletions(-)

diff --git a/src/backends/lalr.c b/src/backends/lalr.c
index db9b88ae..74d37bd2 100644
--- a/src/backends/lalr.c
+++ b/src/backends/lalr.c
@@ -35,16 +35,6 @@ static size_t follow_transition(const HLRTable *table, size_t x, HCFChoice *A)
   return action->nextstate;
 }
 
-static inline HLRTransition *transition(HArena *arena,
-                                        size_t x, const HCFChoice *A, size_t y)
-{
-  HLRTransition *t = h_arena_malloc(arena, sizeof(HLRTransition));
-  t->from = x;
-  t->symbol = A;
-  t->to = y;
-  return t;
-}
-
 // no-op on terminal symbols
 static void transform_productions(const HLRTable *table, HLREnhGrammar *eg,
                                   size_t x, HCFChoice *xAy)
@@ -69,8 +59,8 @@ static void transform_productions(const HLRTable *table, HLREnhGrammar *eg,
     HCFChoice **iBj = items;
     for(; *B; B++, iBj++) {
       size_t j = follow_transition(table, i, *B);
-      HLRTransition *i_B_j = transition(arena, i, *B, j);
-      *iBj = h_hashtable_get(eg->tmap, i_B_j);
+      HLRTransition i_B_j = {i, *B, j};
+      *iBj = h_hashtable_get(eg->tmap, &i_B_j);
       assert(*iBj != NULL);
       i = j;
     }
-- 
GitLab