]> git.saurik.com Git - bison.git/blobdiff - src/lalr.c
* src/lalr.c (initialize_F): Improve variable locality.
[bison.git] / src / lalr.c
index 54b0391cac24d5ded9b9cc5bd6dfbc942ea95995..c2554dcf5c5215fdfa3e4519468d57c80bc8514d 100644 (file)
@@ -356,24 +356,14 @@ map_goto (int state, int symbol)
 static void
 initialize_F (void)
 {
 static void
 initialize_F (void)
 {
-  int i;
-  int j;
-  short *edge;
-  unsigned *rowp;
-  short *rp;
-  short **reads;
-  int nedges;
-  int symbol;
-  int nwords;
+  short **reads = XCALLOC (short *, ngotos);
+  short *edge = XCALLOC (short, ngotos + 1);
+  int nedges = 0;
 
 
-  nwords = ngotos * tokensetsize;
-  F = XCALLOC (unsigned, nwords);
+  int i;
 
 
-  reads = XCALLOC (short *, ngotos);
-  edge = XCALLOC (short, ngotos + 1);
-  nedges = 0;
+  F = XCALLOC (unsigned, ngotos * tokensetsize);
 
 
-  rowp = F;
   for (i = 0; i < ngotos; i++)
     {
       int stateno = to_state[i];
   for (i = 0; i < ngotos; i++)
     {
       int stateno = to_state[i];
@@ -381,34 +371,30 @@ initialize_F (void)
 
       if (sp)
        {
 
       if (sp)
        {
+         int j;
          for (j = 0; j < sp->nshifts; 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;
              if (ISVAR (symbol))
                break;
-             SETBIT (rowp, symbol);
+             SETBIT (F + i * tokensetsize, symbol);
            }
 
          for (; j < sp->nshifts; j++)
            {
            }
 
          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)
            {
              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;
            }
        }
              nedges = 0;
            }
        }
-
-      rowp += tokensetsize;
     }
 
   digraph (reads);
     }
 
   digraph (reads);