String buffers, part 2d: basic string buffer methods.

Sponsored by fmad.io.
This commit is contained in:
Mike Pall
2021-06-01 05:16:32 +02:00
parent edd5cbadc5
commit a119497bec
18 changed files with 816 additions and 85 deletions

View File

@@ -164,6 +164,10 @@ const char *lj_strfmt_wstrnum(lua_State *L, cTValue *o, MSize *lenp)
if (tvisstr(o)) {
*lenp = strV(o)->len;
return strVdata(o);
} else if (tvisbuf(o)) {
SBufExt *sbx = bufV(o);
*lenp = sbufxlen(sbx);
return sbx->r;
} else if (tvisint(o)) {
sb = lj_strfmt_putint(lj_buf_tmp_(L), intV(o));
} else if (tvisnum(o)) {
@@ -421,6 +425,10 @@ int lj_strfmt_putarg(lua_State *L, SBuf *sb, int arg, int retry)
if (LJ_LIKELY(tvisstr(o))) {
len = strV(o)->len;
s = strVdata(o);
} else if (tvisbuf(o)) {
SBufExt *sbx = bufV(o);
len = sbufxlen(sbx);
s = sbx->r;
} else {
GCstr *str = lj_strfmt_obj(L, o);
len = str->len;