lua

A copy of the Lua development repository
Log | Files | Refs | README

commit 10bdd838440b082aaf70748571b443f7c941db81
parent fbfa1cbe9becd8e270ed4567260e5b73cbaf6d1a
Author: Roberto Ierusalimschy <roberto@inf.puc-rio.br>
Date:   Fri, 25 Nov 1994 17:26:44 -0200

new hash function; hash value for strings are kept with the string

Diffstat:
Mtree.c | 4+++-
Mtree.h | 3++-
2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/tree.c b/tree.c @@ -3,7 +3,7 @@ ** TecCGraf - PUC-Rio */ -char *rcs_tree="$Id: tree.c,v 1.9 1994/11/18 19:27:38 roberto Exp roberto $"; +char *rcs_tree="$Id: tree.c,v 1.10 1994/11/23 14:31:11 roberto Stab roberto $"; #include <string.h> @@ -37,6 +37,7 @@ static TreeNode *tree_create (TreeNode **node, char *str) (*node)->left = (*node)->right = NULL; strcpy((*node)->ts.str, str); (*node)->ts.marked = 0; + (*node)->ts.hash = 0; (*node)->varindex = (*node)->constindex = NOT_USED; return *node; } @@ -59,6 +60,7 @@ TaggedString *lua_createstring (char *str) lua_pack(); newString = (StringNode *)luaI_malloc(sizeof(StringNode)+strlen(str)); newString->ts.marked = 0; + newString->ts.hash = 0; strcpy(newString->ts.str, str); newString->next = string_root; string_root = newString; diff --git a/tree.h b/tree.h @@ -1,7 +1,7 @@ /* ** tree.h ** TecCGraf - PUC-Rio -** $Id: tree.h,v 1.5 1994/11/18 19:27:38 roberto Exp roberto $ +** $Id: tree.h,v 1.6 1994/11/23 14:31:11 roberto Stab roberto $ */ #ifndef tree_h @@ -13,6 +13,7 @@ typedef struct TaggedString { + unsigned long hash; /* 0 if not initialized */ char marked; /* for garbage collection */ char str[1]; /* \0 byte already reserved */ } TaggedString;