ref: c5eccbe072cc7b149654391b95eca948069bbfcd
parent: d36beef46ad1ba675c819334289edc9308cf3fc7
author: qwx <qwx@sciops.net>
date: Sun Oct 26 06:21:04 EDT 2025
shorten Cell type by at least 8 bytes by rearranging it
--- a/awk.h
+++ b/awk.h
@@ -54,10 +54,10 @@
typedef struct Cell {uchar ctype; /* OCELL, OBOOL, OJUMP, etc. */
uchar csub; /* CCON, CTEMP, CFLD, etc. */
+ short tval; /* type info: STR|NUM|ARR|FCN|FLD|CON|DONTFREE */
char *nval; /* name, for variables only */
char *sval; /* string value */
Awkfloat fval; /* value as number */
- int tval; /* type info: STR|NUM|ARR|FCN|FLD|CON|DONTFREE */
struct Cell *cnext; /* ptr to next if chained */
} Cell;
--- a/lib.c
+++ b/lib.c
@@ -25,8 +25,8 @@
int argno = 1; /* current input argument number */
extern Awkfloat *AARGC;
-static Cell dollar0 = { OCELL, CFLD, nil, EMPTY, 0.0, REC|STR|DONTFREE };-static Cell dollar1 = { OCELL, CFLD, nil, EMPTY, 0.0, FLD|STR|DONTFREE };+static Cell dollar0 = { OCELL, CFLD, REC|STR|DONTFREE, nil, EMPTY, 0.0 };+static Cell dollar1 = { OCELL, CFLD, FLD|STR|DONTFREE, nil, EMPTY, 0.0 };void recinit(unsigned int n)
{--- a/run.c
+++ b/run.c
@@ -12,23 +12,23 @@
Node *winner = nil; /* root of parse tree */
Cell *tmps; /* free temporary cells for execution */
-static Cell truecell ={ OBOOL, BTRUE, 0, 0, 1.0, NUM };+static Cell truecell ={ OBOOL, BTRUE, NUM, 0, 0, 1.0 };Cell *True = &truecell;
-static Cell falsecell ={ OBOOL, BFALSE, 0, 0, 0.0, NUM };+static Cell falsecell ={ OBOOL, BFALSE, NUM, 0, 0, 0.0 };Cell *False = &falsecell;
-static Cell breakcell ={ OJUMP, JBREAK, 0, 0, 0.0, NUM };+static Cell breakcell ={ OJUMP, JBREAK, NUM, 0, 0, 0.0 };Cell *jbreak = &breakcell;
-static Cell contcell ={ OJUMP, JCONT, 0, 0, 0.0, NUM };+static Cell contcell ={ OJUMP, JCONT, NUM, 0, 0, 0.0 };Cell *jcont = &contcell;
-static Cell nextcell ={ OJUMP, JNEXT, 0, 0, 0.0, NUM };+static Cell nextcell ={ OJUMP, JNEXT, NUM, 0, 0, 0.0 };Cell *jnext = &nextcell;
-static Cell nextfilecell ={ OJUMP, JNEXTFILE, 0, 0, 0.0, NUM };+static Cell nextfilecell ={ OJUMP, JNEXTFILE, NUM, 0, 0, 0.0 };Cell *jnextfile = &nextfilecell;
-static Cell exitcell ={ OJUMP, JEXIT, 0, 0, 0.0, NUM };+static Cell exitcell ={ OJUMP, JEXIT, NUM, 0, 0, 0.0 };Cell *jexit = &exitcell;
-static Cell retcell ={ OJUMP, JRET, 0, 0, 0.0, NUM };+static Cell retcell ={ OJUMP, JRET, NUM, 0, 0, 0.0 };Cell *jret = &retcell;
-static Cell tempcell ={ OCELL, CTEMP, 0, EMPTY, 0.0, NUM|STR|DONTFREE };+static Cell tempcell ={ OCELL, CTEMP, NUM|STR|DONTFREE, 0, EMPTY, 0.0 };Node *curnode = nil; /* the node being executed, for debugging */
@@ -200,7 +200,7 @@
Cell *call(Node **a, int) /* function call. very kludgy and fragile */
{- static Cell newcopycell = { OCELL, CCOPY, 0, EMPTY, 0.0, NUM|STR|DONTFREE };+ static Cell newcopycell = { OCELL, CCOPY, NUM|STR|DONTFREE, 0, EMPTY, 0.0 };int i, ncall, ndef;
Node *x;
Cell *args[NARGS], *oargs[NARGS]; /* BUG: fixed size arrays */
--
⑨