diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1994-11-25 17:27:03 -0200 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1994-11-25 17:27:03 -0200 |
commit | 10bdd838440b082aaf70748571b443f7c941db81 (patch) | |
tree | 07b842429d1bdba801655088d96674dbed2cb612 | |
parent | fbfa1cbe9becd8e270ed4567260e5b73cbaf6d1a (diff) | |
download | lua-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.c | 4 | ||||
-rw-r--r-- | tree.h | 3 |
2 files changed, 5 insertions, 2 deletions
@@ -3,7 +3,7 @@ | |||
3 | ** TecCGraf - PUC-Rio | 3 | ** TecCGraf - PUC-Rio |
4 | */ | 4 | */ |
5 | 5 | ||
6 | char *rcs_tree="$Id: tree.c,v 1.9 1994/11/18 19:27:38 roberto Exp roberto $"; | 6 | char *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; |
@@ -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 | ||
14 | typedef struct TaggedString | 14 | typedef 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; |