From dcff9b85a3cef778af60ad4426f91262ba815931 Mon Sep 17 00:00:00 2001 From: William Wilgus Date: Tue, 11 May 2021 21:35:41 -0400 Subject: 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 --- apps/plugins/lua/rockaux.c | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) (limited to 'apps/plugins/lua/rockaux.c') 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) { brk = strpbrk_n(ch+1, max_ch, break_chars); chars_next_break = (brk - ch); - if (chars_next_break < 2 || w + (ch_w * chars_next_break) > max_w) + if (brk && + (chars_next_break < 2 || w + (ch_w * chars_next_break) > max_w)) { if (!isprint(line[linepos])) { @@ -226,7 +227,7 @@ int get_current_path(lua_State *L, int level) } } - lua_pushnil(L); + lua_pushnil(L); return 1; } @@ -250,25 +251,32 @@ int filetol(int fd, long *num) while (rb->read(fd, &chbuf, 1) == 1) { - if(!isspace(chbuf) || retn == 1) + if(retn || !isspace(chbuf)) { - if(chbuf == '0') /* strip preceeding zeros */ + switch(chbuf) { - *num = 0; - retn = 1; - } - else if(chbuf == '-' && retn != 1) - neg = true; - else - { - rb->lseek(fd, -1, SEEK_CUR); - break; + case '-': + { + if (retn) /* 0 preceeds, this negative sign must be in error */ + goto get_digits; + neg = true; + continue; + } + case '0': /* strip preceeding zeros */ + { + *num = 0; + retn = 1; + continue; + } + default: + goto get_digits; } } } while (rb->read(fd, &chbuf, 1) == 1) { +get_digits: if(!isdigit(chbuf)) { rb->lseek(fd, -1, SEEK_CUR); -- cgit v1.2.3