aboutsummaryrefslogtreecommitdiff
path: root/ldump.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 /ldump.c
parent99a1c06ea34c823e7692deac3a23fec4831d8f79 (diff)
downloadlua-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 'ldump.c')
-rw-r--r--ldump.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/ldump.c b/ldump.c
index 1078910f..5f0b7a46 100644
--- a/ldump.c
+++ b/ldump.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ldump.c,v 2.22 2014/02/28 12:25:12 roberto Exp roberto $ 2** $Id: ldump.c,v 2.23 2014/02/28 16:13:01 roberto Exp roberto $
3** save precompiled Lua chunks 3** save precompiled Lua chunks
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -60,16 +60,16 @@ static void DumpInteger(lua_Integer x, DumpState* D)
60 60
61static void DumpString(const TString* s, DumpState* D) 61static void DumpString(const TString* s, DumpState* D)
62{ 62{
63 if (s==NULL) 63 if (s==NULL) DumpByte(0,D);
64 { 64 else {
65 size_t size=0; 65 size_t size = s->tsv.len+1; /* include trailing '\0' */
66 DumpVar(size,D); 66 if (size < 0xFF) DumpByte(size,D);
67 } 67 else
68 else 68 {
69 { 69 DumpByte(0xFF,D);
70 size_t size=s->tsv.len+1; /* include trailing '\0' */ 70 DumpVar(size,D);
71 DumpVar(size,D); 71 }
72 DumpBlock(getstr(s),size*sizeof(char),D); 72 DumpVector(getstr(s),size-1,D); /* no need to save '\0' */
73 } 73 }
74} 74}
75 75