Lua does not need all those different types...
This commit is contained in:
11
lstring.c
11
lstring.c
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
** $Id: lstring.c,v 1.77 2002/11/13 11:32:26 roberto Exp roberto $
|
||||
** $Id: lstring.c,v 1.78 2002/12/04 17:38:31 roberto Exp roberto $
|
||||
** String table (keeps all strings handled by Lua)
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
@@ -34,7 +34,7 @@ void luaS_resize (lua_State *L, int newsize) {
|
||||
GCObject *p = tb->hash[i];
|
||||
while (p) { /* for each node in the list */
|
||||
GCObject *next = p->gch.next; /* save next */
|
||||
lu_hash h = gcotots(p)->tsv.hash;
|
||||
unsigned int h = gcotots(p)->tsv.hash;
|
||||
int h1 = lmod(h, newsize); /* new position */
|
||||
lua_assert(cast(int, h%newsize) == lmod(h, newsize));
|
||||
p->gch.next = newhash[h1]; /* chain it */
|
||||
@@ -48,7 +48,8 @@ void luaS_resize (lua_State *L, int newsize) {
|
||||
}
|
||||
|
||||
|
||||
static TString *newlstr (lua_State *L, const char *str, size_t l, lu_hash h) {
|
||||
static TString *newlstr (lua_State *L, const char *str, size_t l,
|
||||
unsigned int h) {
|
||||
TString *ts = cast(TString *, luaM_malloc(L, sizestring(l)));
|
||||
stringtable *tb;
|
||||
ts->tsv.len = l;
|
||||
@@ -63,7 +64,7 @@ static TString *newlstr (lua_State *L, const char *str, size_t l, lu_hash h) {
|
||||
ts->tsv.next = tb->hash[h]; /* chain new entry */
|
||||
tb->hash[h] = valtogco(ts);
|
||||
tb->nuse++;
|
||||
if (tb->nuse > cast(ls_nstr, tb->size) && tb->size <= MAX_INT/2)
|
||||
if (tb->nuse > cast(lu_int32, tb->size) && tb->size <= MAX_INT/2)
|
||||
luaS_resize(L, tb->size*2); /* too crowded */
|
||||
return ts;
|
||||
}
|
||||
@@ -71,7 +72,7 @@ static TString *newlstr (lua_State *L, const char *str, size_t l, lu_hash h) {
|
||||
|
||||
TString *luaS_newlstr (lua_State *L, const char *str, size_t l) {
|
||||
GCObject *o;
|
||||
lu_hash h = (lu_hash)l; /* seed */
|
||||
unsigned int h = cast(unsigned int, l); /* seed */
|
||||
size_t step = (l>>5)+1; /* if string is too long, don't hash all its chars */
|
||||
size_t l1;
|
||||
for (l1=l; l1>=step; l1-=step) /* compute hash */
|
||||
|
||||
Reference in New Issue
Block a user