mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-10-14 10:37:38 -04:00
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
d54659b572
Change-Id: I21d6dcfa32523877efd9f70fb0f88f2a02872649
This commit is contained in:
parent
42240f6990
commit
c6fcb1cf45
10 changed files with 88 additions and 25 deletions
|
@ -107,6 +107,21 @@ static void pushstr (lua_State *L, const char *str) {
|
|||
}
|
||||
|
||||
|
||||
/* ROCKLUA ADDED -- Retrieves C string from TString */
|
||||
const char *luaO_getstring(const TString * ts){
|
||||
const char *string;
|
||||
#ifdef INBINARYSTRINGS
|
||||
if (testbits((ts)->tsv.type, TSTR_INBIN))
|
||||
string = *(cast(const char **, (ts) + 1));
|
||||
else
|
||||
#else
|
||||
if (true)
|
||||
#endif
|
||||
string = cast(const char *, (ts) + 1);
|
||||
return string;
|
||||
}
|
||||
|
||||
|
||||
/* this function handles only `%d', `%c', %f, %p, and `%s' formats */
|
||||
const char *luaO_pushvfstring (lua_State *L, const char *fmt, va_list argp) {
|
||||
int n = 1;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue