aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2009-04-29 14:09:41 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2009-04-29 14:09:41 -0300
commit673c456cbaf8d37e9e71afd2bedc00654235f90d (patch)
treeb79d0ed1c410960db588905469dbe0c404cf2663
parentea445708839d48f03d32817071e5fce1e08c3927 (diff)
downloadlua-673c456cbaf8d37e9e71afd2bedc00654235f90d.tar.gz
lua-673c456cbaf8d37e9e71afd2bedc00654235f90d.tar.bz2
lua-673c456cbaf8d37e9e71afd2bedc00654235f90d.zip
resize string hash table only when new size is smaller than current one
-rw-r--r--lgc.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/lgc.c b/lgc.c
index a170ab1c..9563da82 100644
--- a/lgc.c
+++ b/lgc.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lgc.c,v 2.50 2009/04/17 14:28:06 roberto Exp roberto $ 2** $Id: lgc.c,v 2.51 2009/04/28 19:04:36 roberto Exp roberto $
3** Garbage Collector 3** Garbage Collector
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -589,8 +589,12 @@ static GCObject **sweeplist (lua_State *L, GCObject **p, lu_mem count) {
589 589
590static void checkSizes (lua_State *L) { 590static void checkSizes (lua_State *L) {
591 global_State *g = G(L); 591 global_State *g = G(L);
592 if (g->strt.nuse < cast(lu_int32, g->strt.size)) 592 if (g->strt.nuse < cast(lu_int32, g->strt.size)) {
593 luaS_resize(L, 1 << luaO_ceillog2(g->strt.nuse)); 593 /* size could be the smaller power of 2 larger than 'nuse' */
594 int size = 1 << luaO_ceillog2(g->strt.nuse);
595 if (size < g->strt.size) /* current table too large? */
596 luaS_resize(L, size); /* shrink it */
597 }
594 luaZ_freebuffer(L, &g->buff); 598 luaZ_freebuffer(L, &g->buff);
595} 599}
596 600