> Maybe Lua never has to convert such large numbers.
The current limit is 44, you are worried that 32000 [or 2M] can be too
little?
Not really.
> But to satisfy luaS_newlstr, better pass the correct type?
>
> [...]
> - int len = tostringbuff(obj, buff);
> + size_t len = tostringbuff(obj, buff);
'tostringbuff' gets its result from lua_integer2str or lua_number2str,
which get this length from sprintf (or snprintf), which returns int.
This change would only move the cast to another place.
One step.
To remove all casts from strings, as possible.
One another example.
Maybe, is not useful to capture a string more than 2GB, but,
Lua can!
diff --git a/lstrlib.c b/lstrlib.c
index 2ba8bde4..18d63bb7 100644
--- a/lstrlib.c
+++ b/lstrlib.c
@@ -529,7 +529,7 @@ static const char *min_expand (MatchState *ms, const char *s,
static const char *start_capture (MatchState *ms, const char *s,
- const char *p, int what) {
+ const char *p, size_t what) {
const char *res;
int level = ms->level;
if (level >= LUA_MAXCAPTURES) luaL_error(ms->L, "too many captures");
.len is ptrdiff_t.