diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2003-04-28 16:26:16 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2003-04-28 16:26:16 -0300 |
commit | 572a69df78b2636642e9c520ebc8c1d2efa16afe (patch) | |
tree | 0e1e6f042e63f1d0e8aabc692692f2fcc42efb75 /lstring.c | |
parent | 943c82b37622bd2321d4fbb361d99f4495ceed2f (diff) | |
download | lua-572a69df78b2636642e9c520ebc8c1d2efa16afe.tar.gz lua-572a69df78b2636642e9c520ebc8c1d2efa16afe.tar.bz2 lua-572a69df78b2636642e9c520ebc8c1d2efa16afe.zip |
Lua does not need all those different types...
Diffstat (limited to 'lstring.c')
-rw-r--r-- | lstring.c | 11 |
1 files changed, 6 insertions, 5 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lstring.c,v 1.77 2002/11/13 11:32:26 roberto Exp roberto $ | 2 | ** $Id: lstring.c,v 1.78 2002/12/04 17:38:31 roberto Exp roberto $ |
3 | ** String table (keeps all strings handled by Lua) | 3 | ** String table (keeps all strings handled by Lua) |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -34,7 +34,7 @@ void luaS_resize (lua_State *L, int newsize) { | |||
34 | GCObject *p = tb->hash[i]; | 34 | GCObject *p = tb->hash[i]; |
35 | while (p) { /* for each node in the list */ | 35 | while (p) { /* for each node in the list */ |
36 | GCObject *next = p->gch.next; /* save next */ | 36 | GCObject *next = p->gch.next; /* save next */ |
37 | lu_hash h = gcotots(p)->tsv.hash; | 37 | unsigned int h = gcotots(p)->tsv.hash; |
38 | int h1 = lmod(h, newsize); /* new position */ | 38 | int h1 = lmod(h, newsize); /* new position */ |
39 | lua_assert(cast(int, h%newsize) == lmod(h, newsize)); | 39 | lua_assert(cast(int, h%newsize) == lmod(h, newsize)); |
40 | p->gch.next = newhash[h1]; /* chain it */ | 40 | p->gch.next = newhash[h1]; /* chain it */ |
@@ -48,7 +48,8 @@ void luaS_resize (lua_State *L, int newsize) { | |||
48 | } | 48 | } |
49 | 49 | ||
50 | 50 | ||
51 | static TString *newlstr (lua_State *L, const char *str, size_t l, lu_hash h) { | 51 | static TString *newlstr (lua_State *L, const char *str, size_t l, |
52 | unsigned int h) { | ||
52 | TString *ts = cast(TString *, luaM_malloc(L, sizestring(l))); | 53 | TString *ts = cast(TString *, luaM_malloc(L, sizestring(l))); |
53 | stringtable *tb; | 54 | stringtable *tb; |
54 | ts->tsv.len = l; | 55 | ts->tsv.len = l; |
@@ -63,7 +64,7 @@ static TString *newlstr (lua_State *L, const char *str, size_t l, lu_hash h) { | |||
63 | ts->tsv.next = tb->hash[h]; /* chain new entry */ | 64 | ts->tsv.next = tb->hash[h]; /* chain new entry */ |
64 | tb->hash[h] = valtogco(ts); | 65 | tb->hash[h] = valtogco(ts); |
65 | tb->nuse++; | 66 | tb->nuse++; |
66 | if (tb->nuse > cast(ls_nstr, tb->size) && tb->size <= MAX_INT/2) | 67 | if (tb->nuse > cast(lu_int32, tb->size) && tb->size <= MAX_INT/2) |
67 | luaS_resize(L, tb->size*2); /* too crowded */ | 68 | luaS_resize(L, tb->size*2); /* too crowded */ |
68 | return ts; | 69 | return ts; |
69 | } | 70 | } |
@@ -71,7 +72,7 @@ static TString *newlstr (lua_State *L, const char *str, size_t l, lu_hash h) { | |||
71 | 72 | ||
72 | TString *luaS_newlstr (lua_State *L, const char *str, size_t l) { | 73 | TString *luaS_newlstr (lua_State *L, const char *str, size_t l) { |
73 | GCObject *o; | 74 | GCObject *o; |
74 | lu_hash h = (lu_hash)l; /* seed */ | 75 | unsigned int h = cast(unsigned int, l); /* seed */ |
75 | size_t step = (l>>5)+1; /* if string is too long, don't hash all its chars */ | 76 | size_t step = (l>>5)+1; /* if string is too long, don't hash all its chars */ |
76 | size_t l1; | 77 | size_t l1; |
77 | for (l1=l; l1>=step; l1-=step) /* compute hash */ | 78 | for (l1=l; l1>=step; l1-=step) /* compute hash */ |