diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2014-03-01 12:18:44 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2014-03-01 12:18:44 -0300 |
commit | f69e0ade19af4d997f52c03881362a6961383487 (patch) | |
tree | 4ee16763cb070c92e2d985bc3a57b73e99698b53 /lundump.c | |
parent | 99a1c06ea34c823e7692deac3a23fec4831d8f79 (diff) | |
download | lua-f69e0ade19af4d997f52c03881362a6961383487.tar.gz lua-f69e0ade19af4d997f52c03881362a6961383487.tar.bz2 lua-f69e0ade19af4d997f52c03881362a6961383487.zip |
no need to store a full 'size_t' fo the size of (frequent) small strings
Diffstat (limited to 'lundump.c')
-rw-r--r-- | lundump.c | 10 |
1 files changed, 5 insertions, 5 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lundump.c,v 2.28 2014/02/28 12:25:12 roberto Exp roberto $ | 2 | ** $Id: lundump.c,v 2.29 2014/02/28 16:13:01 roberto Exp roberto $ |
3 | ** load precompiled Lua chunks | 3 | ** load precompiled Lua chunks |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -76,15 +76,15 @@ static lua_Integer LoadInteger(LoadState* S) | |||
76 | 76 | ||
77 | static TString* LoadString(LoadState* S) | 77 | static TString* LoadString(LoadState* S) |
78 | { | 78 | { |
79 | size_t size; | 79 | size_t size = LoadByte(S); |
80 | LoadVar(S,size); | 80 | if (size == 0xFF) LoadVar(S,size); |
81 | if (size==0) | 81 | if (size==0) |
82 | return NULL; | 82 | return NULL; |
83 | else | 83 | else |
84 | { | 84 | { |
85 | char* s=luaZ_openspace(S->L,S->b,size); | 85 | char* s=luaZ_openspace(S->L,S->b,--size); |
86 | LoadVector(S,s,size); | 86 | LoadVector(S,s,size); |
87 | return luaS_newlstr(S->L,s,size-1); /* remove trailing '\0' */ | 87 | return luaS_newlstr(S->L,s,size); |
88 | } | 88 | } |
89 | } | 89 | } |
90 | 90 | ||