From f69e0ade19af4d997f52c03881362a6961383487 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Sat, 1 Mar 2014 12:18:44 -0300 Subject: no need to store a full 'size_t' fo the size of (frequent) small strings --- ldump.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'ldump.c') diff --git a/ldump.c b/ldump.c index 1078910f..5f0b7a46 100644 --- a/ldump.c +++ b/ldump.c @@ -1,5 +1,5 @@ /* -** $Id: ldump.c,v 2.22 2014/02/28 12:25:12 roberto Exp roberto $ +** $Id: ldump.c,v 2.23 2014/02/28 16:13:01 roberto Exp roberto $ ** save precompiled Lua chunks ** See Copyright Notice in lua.h */ @@ -60,16 +60,16 @@ static void DumpInteger(lua_Integer x, DumpState* D) static void DumpString(const TString* s, DumpState* D) { - if (s==NULL) - { - size_t size=0; - DumpVar(size,D); - } - else - { - size_t size=s->tsv.len+1; /* include trailing '\0' */ - DumpVar(size,D); - DumpBlock(getstr(s),size*sizeof(char),D); + if (s==NULL) DumpByte(0,D); + else { + size_t size = s->tsv.len+1; /* include trailing '\0' */ + if (size < 0xFF) DumpByte(size,D); + else + { + DumpByte(0xFF,D); + DumpVar(size,D); + } + DumpVector(getstr(s),size-1,D); /* no need to save '\0' */ } } -- cgit v1.2.3-55-g6feb