diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1996-02-14 16:11:09 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1996-02-14 16:11:09 -0300 |
| commit | 15c17c24facb6d7e6f837b87927a54a40a54aa36 (patch) | |
| tree | 4d0f1d0c49133ea06223627e1abd247c0ad78b6b /tree.c | |
| parent | 45cf24485de6738b44cd9a68738ae6a11b3827db (diff) | |
| download | lua-15c17c24facb6d7e6f837b87927a54a40a54aa36.tar.gz lua-15c17c24facb6d7e6f837b87927a54a40a54aa36.tar.bz2 lua-15c17c24facb6d7e6f837b87927a54a40a54aa36.zip | |
small improvements
Diffstat (limited to 'tree.c')
| -rw-r--r-- | tree.c | 10 |
1 files changed, 4 insertions, 6 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.16 1996/02/12 18:32:40 roberto Exp roberto $"; | 6 | char *rcs_tree="$Id: tree.c,v 1.17 1996/02/14 13:35:51 roberto Exp roberto $"; |
| 7 | 7 | ||
| 8 | 8 | ||
| 9 | #include <string.h> | 9 | #include <string.h> |
| @@ -16,8 +16,6 @@ char *rcs_tree="$Id: tree.c,v 1.16 1996/02/12 18:32:40 roberto Exp roberto $"; | |||
| 16 | #include "table.h" | 16 | #include "table.h" |
| 17 | 17 | ||
| 18 | 18 | ||
| 19 | #define lua_streq(a,b) (a[0] == b[0] && strcmp(a,b) == 0) | ||
| 20 | |||
| 21 | #define NUM_HASHS 64 | 19 | #define NUM_HASHS 64 |
| 22 | 20 | ||
| 23 | typedef struct { | 21 | typedef struct { |
| @@ -30,7 +28,7 @@ static int initialized = 0; | |||
| 30 | 28 | ||
| 31 | static stringtable string_root[NUM_HASHS]; | 29 | static stringtable string_root[NUM_HASHS]; |
| 32 | 30 | ||
| 33 | static TaggedString EMPTY = {NOT_USED, NOT_USED, 0, 0, {0}}; | 31 | static TaggedString EMPTY = {NOT_USED, NOT_USED, 0, 2, {0}}; |
| 34 | 32 | ||
| 35 | 33 | ||
| 36 | static unsigned long hash (char *str) | 34 | static unsigned long hash (char *str) |
| @@ -92,7 +90,7 @@ static TaggedString *insert (char *str, stringtable *tb) | |||
| 92 | { | 90 | { |
| 93 | if (tb->hash[i] == &EMPTY) | 91 | if (tb->hash[i] == &EMPTY) |
| 94 | j = i; | 92 | j = i; |
| 95 | else if (lua_streq(str, tb->hash[i]->str)) | 93 | else if (strcmp(str, tb->hash[i]->str) == 0) |
| 96 | return tb->hash[i]; | 94 | return tb->hash[i]; |
| 97 | i = (i+1)%tb->size; | 95 | i = (i+1)%tb->size; |
| 98 | } | 96 | } |
| @@ -130,7 +128,7 @@ Long lua_strcollector (void) | |||
| 130 | for (j=0; j<tb->size; j++) | 128 | for (j=0; j<tb->size; j++) |
| 131 | { | 129 | { |
| 132 | TaggedString *t = tb->hash[j]; | 130 | TaggedString *t = tb->hash[j]; |
| 133 | if (t != NULL && t != &EMPTY && t->marked <= 1) | 131 | if (t != NULL && t->marked <= 1) |
| 134 | { | 132 | { |
| 135 | if (t->marked) | 133 | if (t->marked) |
| 136 | t->marked = 0; | 134 | t->marked = 0; |
