summaryrefslogtreecommitdiff
path: root/lundump.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2014-03-01 12:18:44 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2014-03-01 12:18:44 -0300
commitf69e0ade19af4d997f52c03881362a6961383487 (patch)
tree4ee16763cb070c92e2d985bc3a57b73e99698b53 /lundump.c
parent99a1c06ea34c823e7692deac3a23fec4831d8f79 (diff)
downloadlua-github-f69e0ade19af4d997f52c03881362a6961383487.tar.gz
no need to store a full 'size_t' fo the size of (frequent) small strings
Diffstat (limited to 'lundump.c')
-rw-r--r--lundump.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/lundump.c b/lundump.c
index ef7444e0..9a3ee218 100644
--- a/lundump.c
+++ b/lundump.c
@@ -1,5 +1,5 @@
/*
-** $Id: lundump.c,v 2.28 2014/02/28 12:25:12 roberto Exp roberto $
+** $Id: lundump.c,v 2.29 2014/02/28 16:13:01 roberto Exp roberto $
** load precompiled Lua chunks
** See Copyright Notice in lua.h
*/
@@ -76,15 +76,15 @@ static lua_Integer LoadInteger(LoadState* S)
static TString* LoadString(LoadState* S)
{
- size_t size;
- LoadVar(S,size);
+ size_t size = LoadByte(S);
+ if (size == 0xFF) LoadVar(S,size);
if (size==0)
return NULL;
else
{
- char* s=luaZ_openspace(S->L,S->b,size);
+ char* s=luaZ_openspace(S->L,S->b,--size);
LoadVector(S,s,size);
- return luaS_newlstr(S->L,s,size-1); /* remove trailing '\0' */
+ return luaS_newlstr(S->L,s,size);
}
}