bison-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

07-fyi-initialize-F.patch


From: Akim Demaille
Subject: 07-fyi-initialize-F.patch
Date: Wed, 05 Dec 2001 08:24:37 +0100

Index: ChangeLog
from  Akim Demaille  <address@hidden>

        * src/lalr.c (initialize_F): Improve variable locality.
        Avoid variables used as mere abbreviations.

Index: src/lalr.c
--- src/lalr.c Sat, 01 Dec 2001 14:08:27 +0100 akim
+++ src/lalr.c Sat, 01 Dec 2001 14:30:08 +0100 akim
@@ -356,24 +356,14 @@
 static void
 initialize_F (void)
 {
+  short **reads = XCALLOC (short *, ngotos);
+  short *edge = XCALLOC (short, ngotos + 1);
+  int nedges = 0;
+
   int i;
-  int j;
-  short *edge;
-  unsigned *rowp;
-  short *rp;
-  short **reads;
-  int nedges;
-  int symbol;
-  int nwords;
-
-  nwords = ngotos * tokensetsize;
-  F = XCALLOC (unsigned, nwords);
-
-  reads = XCALLOC (short *, ngotos);
-  edge = XCALLOC (short, ngotos + 1);
-  nedges = 0;

-  rowp = F;
+  F = XCALLOC (unsigned, ngotos * tokensetsize);
+
   for (i = 0; i < ngotos; i++)
     {
       int stateno = to_state[i];
@@ -381,34 +371,30 @@

       if (sp)
        {
+         int j;
          for (j = 0; j < sp->nshifts; j++)
            {
-             symbol = state_table[sp->shifts[j]].accessing_symbol;
+             int symbol = state_table[sp->shifts[j]].accessing_symbol;
              if (ISVAR (symbol))
                break;
-             SETBIT (rowp, symbol);
+             SETBIT (F + i * tokensetsize, symbol);
            }

          for (; j < sp->nshifts; j++)
            {
-             symbol = state_table[sp->shifts[j]].accessing_symbol;
+             int symbol = state_table[sp->shifts[j]].accessing_symbol;
              if (nullable[symbol])
                edge[nedges++] = map_goto (stateno, symbol);
            }

          if (nedges)
            {
-             reads[i] = rp = XCALLOC (short, nedges + 1);
-
-             for (j = 0; j < nedges; j++)
-               rp[j] = edge[j];
-
-             rp[nedges] = -1;
+             reads[i] = XCALLOC (short, nedges + 1);
+             shortcpy (reads[i], edge, nedges);
+             reads[i][nedges] = -1;
              nedges = 0;
            }
        }
-
-      rowp += tokensetsize;
     }

   digraph (reads);



reply via email to

[Prev in Thread] Current Thread [Next in Thread]