aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>1994-11-25 17:27:03 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>1994-11-25 17:27:03 -0200
commit10bdd838440b082aaf70748571b443f7c941db81 (patch)
tree07b842429d1bdba801655088d96674dbed2cb612
parentfbfa1cbe9becd8e270ed4567260e5b73cbaf6d1a (diff)
downloadlua-10bdd838440b082aaf70748571b443f7c941db81.tar.gz
lua-10bdd838440b082aaf70748571b443f7c941db81.tar.bz2
lua-10bdd838440b082aaf70748571b443f7c941db81.zip
new hash function; hash value for strings are kept with the string
-rw-r--r--tree.c4
-rw-r--r--tree.h3
2 files changed, 5 insertions, 2 deletions
diff --git a/tree.c b/tree.c
index 90fa64ab..9a9daf19 100644
--- a/tree.c
+++ b/tree.c
@@ -3,7 +3,7 @@
3** TecCGraf - PUC-Rio 3** TecCGraf - PUC-Rio
4*/ 4*/
5 5
6char *rcs_tree="$Id: tree.c,v 1.9 1994/11/18 19:27:38 roberto Exp roberto $"; 6char *rcs_tree="$Id: tree.c,v 1.10 1994/11/23 14:31:11 roberto Stab roberto $";
7 7
8 8
9#include <string.h> 9#include <string.h>
@@ -37,6 +37,7 @@ static TreeNode *tree_create (TreeNode **node, char *str)
37 (*node)->left = (*node)->right = NULL; 37 (*node)->left = (*node)->right = NULL;
38 strcpy((*node)->ts.str, str); 38 strcpy((*node)->ts.str, str);
39 (*node)->ts.marked = 0; 39 (*node)->ts.marked = 0;
40 (*node)->ts.hash = 0;
40 (*node)->varindex = (*node)->constindex = NOT_USED; 41 (*node)->varindex = (*node)->constindex = NOT_USED;
41 return *node; 42 return *node;
42 } 43 }
@@ -59,6 +60,7 @@ TaggedString *lua_createstring (char *str)
59 lua_pack(); 60 lua_pack();
60 newString = (StringNode *)luaI_malloc(sizeof(StringNode)+strlen(str)); 61 newString = (StringNode *)luaI_malloc(sizeof(StringNode)+strlen(str));
61 newString->ts.marked = 0; 62 newString->ts.marked = 0;
63 newString->ts.hash = 0;
62 strcpy(newString->ts.str, str); 64 strcpy(newString->ts.str, str);
63 newString->next = string_root; 65 newString->next = string_root;
64 string_root = newString; 66 string_root = newString;
diff --git a/tree.h b/tree.h
index 14bf9959..149819e9 100644
--- a/tree.h
+++ b/tree.h
@@ -1,7 +1,7 @@
1/* 1/*
2** tree.h 2** tree.h
3** TecCGraf - PUC-Rio 3** TecCGraf - PUC-Rio
4** $Id: tree.h,v 1.5 1994/11/18 19:27:38 roberto Exp roberto $ 4** $Id: tree.h,v 1.6 1994/11/23 14:31:11 roberto Stab roberto $
5*/ 5*/
6 6
7#ifndef tree_h 7#ifndef tree_h
@@ -13,6 +13,7 @@
13 13
14typedef struct TaggedString 14typedef struct TaggedString
15{ 15{
16 unsigned long hash; /* 0 if not initialized */
16 char marked; /* for garbage collection */ 17 char marked; /* for garbage collection */
17 char str[1]; /* \0 byte already reserved */ 18 char str[1]; /* \0 byte already reserved */
18} TaggedString; 19} TaggedString;