aboutsummaryrefslogtreecommitdiff
path: root/llex.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2025-03-31 13:44:41 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2025-03-31 13:44:41 -0300
commitf4123b2fc2a662c08e3d7edc721241c251a22c4b (patch)
treef856da11d3134e1755bdb11192394dfd5c3595cd /llex.c
parent37a1b72706b6e55e60b8d73bcbe269921976825e (diff)
downloadlua-f4123b2fc2a662c08e3d7edc721241c251a22c4b.tar.gz
lua-f4123b2fc2a662c08e3d7edc721241c251a22c4b.tar.bz2
lua-f4123b2fc2a662c08e3d7edc721241c251a22c4b.zip
Growth factor of 1.5 for stack and lexical buffer
Diffstat (limited to 'llex.c')
-rw-r--r--llex.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/llex.c b/llex.c
index 1c4227ca..4b5a1f75 100644
--- a/llex.c
+++ b/llex.c
@@ -62,10 +62,10 @@ static l_noret lexerror (LexState *ls, const char *msg, int token);
62static void save (LexState *ls, int c) { 62static void save (LexState *ls, int c) {
63 Mbuffer *b = ls->buff; 63 Mbuffer *b = ls->buff;
64 if (luaZ_bufflen(b) + 1 > luaZ_sizebuffer(b)) { 64 if (luaZ_bufflen(b) + 1 > luaZ_sizebuffer(b)) {
65 size_t newsize; 65 size_t newsize = luaZ_sizebuffer(b); /* get old size */;
66 if (luaZ_sizebuffer(b) >= MAX_SIZE/2) 66 if (newsize >= (MAX_SIZE/3 * 2)) /* larger than MAX_SIZE/1.5 ? */
67 lexerror(ls, "lexical element too long", 0); 67 lexerror(ls, "lexical element too long", 0);
68 newsize = luaZ_sizebuffer(b) * 2; 68 newsize += (newsize >> 1); /* new size is 1.5 times the old one */
69 luaZ_resizebuffer(ls->L, b, newsize); 69 luaZ_resizebuffer(ls->L, b, newsize);
70 } 70 }
71 b->buffer[luaZ_bufflen(b)++] = cast_char(c); 71 b->buffer[luaZ_bufflen(b)++] = cast_char(c);