diff options
author | William Wilgus <wilgus.william@gmail.com> | 2021-05-11 21:35:41 -0400 |
---|---|---|
committer | William Wilgus <me.theuser@yahoo.com> | 2021-05-19 23:28:35 +0000 |
commit | dcff9b85a3cef778af60ad4426f91262ba815931 (patch) | |
tree | 8f58cd59a2115ac70cd4df6e462ded09c81375fc /apps/plugins/lua/rockaux.c | |
parent | 0c6217757528b185c3f8628c062a2a688a8adaf8 (diff) | |
download | rockbox-dcff9b85a3cef778af60ad4426f91262ba815931.tar.gz rockbox-dcff9b85a3cef778af60ad4426f91262ba815931.zip |
lua latebound function update
return the nextfunction and nil instead of pairs it allows a faster
return to lua rather than calling the lua function
pcall(fnpairs) from c and returning the result back
into lua to kick off the search
yeah, no clue why I didn't realize that before..
testing in x86 and ARM..
its more RAM efficient to do the initial creation
of the stack in lua code for the __pairs functon
its not faster but being that its a one time hit per
iter creation the reduced churn alone should be worth it
along with a reduced peak RAM usage
fix bug where a failed module can not be reloaded
optimize filetol
fix potential bug in splash scroller when no break character is found
Change-Id: I42c922e07039a19138b97c0d0e80cf3cf2426471
Diffstat (limited to 'apps/plugins/lua/rockaux.c')
-rw-r--r-- | apps/plugins/lua/rockaux.c | 34 |
1 files changed, 21 insertions, 13 deletions
diff --git a/apps/plugins/lua/rockaux.c b/apps/plugins/lua/rockaux.c index 058ad313fa..929dea798b 100644 --- a/apps/plugins/lua/rockaux.c +++ b/apps/plugins/lua/rockaux.c | |||
@@ -106,7 +106,8 @@ int splash_scroller(int timeout, const char* str) | |||
106 | { | 106 | { |
107 | brk = strpbrk_n(ch+1, max_ch, break_chars); | 107 | brk = strpbrk_n(ch+1, max_ch, break_chars); |
108 | chars_next_break = (brk - ch); | 108 | chars_next_break = (brk - ch); |
109 | if (chars_next_break < 2 || w + (ch_w * chars_next_break) > max_w) | 109 | if (brk && |
110 | (chars_next_break < 2 || w + (ch_w * chars_next_break) > max_w)) | ||
110 | { | 111 | { |
111 | if (!isprint(line[linepos])) | 112 | if (!isprint(line[linepos])) |
112 | { | 113 | { |
@@ -226,7 +227,7 @@ int get_current_path(lua_State *L, int level) | |||
226 | } | 227 | } |
227 | } | 228 | } |
228 | 229 | ||
229 | lua_pushnil(L); | 230 | lua_pushnil(L); |
230 | return 1; | 231 | return 1; |
231 | } | 232 | } |
232 | 233 | ||
@@ -250,25 +251,32 @@ int filetol(int fd, long *num) | |||
250 | 251 | ||
251 | while (rb->read(fd, &chbuf, 1) == 1) | 252 | while (rb->read(fd, &chbuf, 1) == 1) |
252 | { | 253 | { |
253 | if(!isspace(chbuf) || retn == 1) | 254 | if(retn || !isspace(chbuf)) |
254 | { | 255 | { |
255 | if(chbuf == '0') /* strip preceeding zeros */ | 256 | switch(chbuf) |
256 | { | 257 | { |
257 | *num = 0; | 258 | case '-': |
258 | retn = 1; | 259 | { |
259 | } | 260 | if (retn) /* 0 preceeds, this negative sign must be in error */ |
260 | else if(chbuf == '-' && retn != 1) | 261 | goto get_digits; |
261 | neg = true; | 262 | neg = true; |
262 | else | 263 | continue; |
263 | { | 264 | } |
264 | rb->lseek(fd, -1, SEEK_CUR); | 265 | case '0': /* strip preceeding zeros */ |
265 | break; | 266 | { |
267 | *num = 0; | ||
268 | retn = 1; | ||
269 | continue; | ||
270 | } | ||
271 | default: | ||
272 | goto get_digits; | ||
266 | } | 273 | } |
267 | } | 274 | } |
268 | } | 275 | } |
269 | 276 | ||
270 | while (rb->read(fd, &chbuf, 1) == 1) | 277 | while (rb->read(fd, &chbuf, 1) == 1) |
271 | { | 278 | { |
279 | get_digits: | ||
272 | if(!isdigit(chbuf)) | 280 | if(!isdigit(chbuf)) |
273 | { | 281 | { |
274 | rb->lseek(fd, -1, SEEK_CUR); | 282 | rb->lseek(fd, -1, SEEK_CUR); |