diff options
author | William Wilgus <me.theuser@yahoo.com> | 2018-11-11 18:27:19 -0500 |
---|---|---|
committer | William Wilgus <me.theuser@yahoo.com> | 2019-07-11 00:31:41 +0200 |
commit | c6fcb1cf45b249b059c2d53a062f9a6c7f449047 (patch) | |
tree | 229eacd12461605a8320eb7590ff83eea13538d6 /apps/plugins/lua/lobject.c | |
parent | 42240f6990156fb907a7dce7258be2f1235fab44 (diff) | |
download | rockbox-c6fcb1cf45b249b059c2d53a062f9a6c7f449047.tar.gz rockbox-c6fcb1cf45b249b059c2d53a062f9a6c7f449047.zip |
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
Diffstat (limited to 'apps/plugins/lua/lobject.c')
-rw-r--r-- | apps/plugins/lua/lobject.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/apps/plugins/lua/lobject.c b/apps/plugins/lua/lobject.c index a351ff41da..65a23cf938 100644 --- a/apps/plugins/lua/lobject.c +++ b/apps/plugins/lua/lobject.c | |||
@@ -107,6 +107,21 @@ static void pushstr (lua_State *L, const char *str) { | |||
107 | } | 107 | } |
108 | 108 | ||
109 | 109 | ||
110 | /* ROCKLUA ADDED -- Retrieves C string from TString */ | ||
111 | const char *luaO_getstring(const TString * ts){ | ||
112 | const char *string; | ||
113 | #ifdef INBINARYSTRINGS | ||
114 | if (testbits((ts)->tsv.type, TSTR_INBIN)) | ||
115 | string = *(cast(const char **, (ts) + 1)); | ||
116 | else | ||
117 | #else | ||
118 | if (true) | ||
119 | #endif | ||
120 | string = cast(const char *, (ts) + 1); | ||
121 | return string; | ||
122 | } | ||
123 | |||
124 | |||
110 | /* this function handles only `%d', `%c', %f, %p, and `%s' formats */ | 125 | /* this function handles only `%d', `%c', %f, %p, and `%s' formats */ |
111 | const char *luaO_pushvfstring (lua_State *L, const char *fmt, va_list argp) { | 126 | const char *luaO_pushvfstring (lua_State *L, const char *fmt, va_list argp) { |
112 | int n = 1; | 127 | int n = 1; |