summaryrefslogtreecommitdiff
path: root/lapi.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2015-01-16 14:54:37 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2015-01-16 14:54:37 -0200
commit7e2015a46df7976bddee313b994742e49e420714 (patch)
tree0b2db30f1214a478ccb3664d165c8a431f0d5850 /lapi.c
parent5b01cb39b5ec36c544152351c35c43149d9bbfec (diff)
downloadlua-github-7e2015a46df7976bddee313b994742e49e420714.tar.gz
size of short strings stored in a single byte, to reduce the size
of struct 'TString'
Diffstat (limited to 'lapi.c')
-rw-r--r--lapi.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/lapi.c b/lapi.c
index c2ef6019..9d6123ce 100644
--- a/lapi.c
+++ b/lapi.c
@@ -1,5 +1,5 @@
/*
-** $Id: lapi.c,v 2.243 2014/11/12 13:28:54 roberto Exp roberto $
+** $Id: lapi.c,v 2.244 2014/12/26 14:43:45 roberto Exp roberto $
** Lua API
** See Copyright Notice in lua.h
*/
@@ -382,15 +382,17 @@ LUA_API const char *lua_tolstring (lua_State *L, int idx, size_t *len) {
luaO_tostring(L, o);
lua_unlock(L);
}
- if (len != NULL) *len = tsvalue(o)->len;
+ if (len != NULL)
+ *len = vslen(o);
return svalue(o);
}
LUA_API size_t lua_rawlen (lua_State *L, int idx) {
StkId o = index2addr(L, idx);
- switch (ttnov(o)) {
- case LUA_TSTRING: return tsvalue(o)->len;
+ switch (ttype(o)) {
+ case LUA_TSHRSTR: return tsvalue(o)->shrlen;
+ case LUA_TLNGSTR: return tsvalue(o)->u.lnglen;
case LUA_TUSERDATA: return uvalue(o)->len;
case LUA_TTABLE: return luaH_getn(hvalue(o));
default: return 0;