Closed invpe closed 1 year ago
A workaround is to register a func that does it fast like below:
/* Get a char a string position */
static int _charat(mb_interpreter_t* s, void** l) {
int result = MB_FUNC_OK;
char* arg = 0;
int_t start = 0;
char sub[2];
mb_check(mb_attempt_open_bracket(s, l));
mb_check(mb_pop_string(s, l, &arg));
mb_check(mb_pop_int(s, l, &start));
mb_check(mb_attempt_close_bracket(s, l));
if ( start < 0 || start >= (int_t)strlen(arg))
{
sub[0] = '\0';
}
else
{
sub[0] = arg[start];
sub[1] = '\0';
}
mb_check(mb_push_string(s, l, mb_memdup(sub, 2)));
return result;
}
But i might be overcomplicating things, thus asking if withing MB we've got a better solution than mine ;)
Issue on MBStep
I noticed that
FOR
on Strings is super slow.This simple iteration takes :
More than 0.5sec, running ESP32.
Is there a better way of doing this in mybasic ?