From c6fcb1cf45b249b059c2d53a062f9a6c7f449047 Mon Sep 17 00:00:00 2001 From: William Wilgus Date: Sun, 11 Nov 2018 18:27:19 -0500 Subject: lua inbinary strings Allows saving of ram by reusing strings already stored in the binary and storing a pointer instead of malloc and copy to get them inside the lua state Saves about 1.5K overall Derivative of work by bogdanm RAM optimizations: pseudo RO strings, functions in Flash https://github.com/elua/elua/commit/d54659b5723bcd2b1e3900362398c72c18a9aa0b Change-Id: I21d6dcfa32523877efd9f70fb0f88f2a02872649 --- apps/plugins/lua/lobject.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'apps/plugins/lua/lobject.h') diff --git a/apps/plugins/lua/lobject.h b/apps/plugins/lua/lobject.h index 93288fe0fb..26d2a81b49 100644 --- a/apps/plugins/lua/lobject.h +++ b/apps/plugins/lua/lobject.h @@ -201,13 +201,14 @@ typedef union TString { struct { CommonHeader; lu_byte reserved; + lu_byte type; unsigned int hash; size_t len; } tsv; } TString; -#define getstr(ts) cast(const char *, (ts) + 1) +#define getstr(ts) (luaO_getstring(ts)) /* ROCKLUA ADDED */ #define svalue(o) getstr(rawtsvalue(o)) @@ -371,6 +372,7 @@ LUAI_FUNC int luaO_int2fb (unsigned int x); LUAI_FUNC int luaO_fb2int (int x); LUAI_FUNC int luaO_rawequalObj (const TValue *t1, const TValue *t2); LUAI_FUNC int luaO_str2d (const char *s, lua_Number *result); +LUAI_FUNC const char *luaO_getstring(const TString * ts); /* ROCKLUA ADDED */ LUAI_FUNC const char *luaO_pushvfstring (lua_State *L, const char *fmt, va_list argp); LUAI_FUNC const char *luaO_pushfstring (lua_State *L, const char *fmt, ...); -- cgit v1.2.3