Fuse string creation into concats. Optimize single-char concats.

This commit is contained in:
Mike Pall
2013-04-23 00:56:03 +02:00
parent 2cdf90f068
commit 557391c3b7
4 changed files with 37 additions and 8 deletions

View File

@@ -58,11 +58,12 @@ char *lj_buf_wmem(char *p, const void *q, MSize len)
return p;
}
void lj_buf_putmem(SBuf *sb, const void *q, MSize len)
SBuf * lj_buf_putmem(SBuf *sb, const void *q, MSize len)
{
char *p = lj_buf_more(sb, len);
p = lj_buf_wmem(p, q, len);
setsbufP(sb, p);
return sb;
}
#if LJ_HASJIT
@@ -75,6 +76,14 @@ SBuf * LJ_FASTCALL lj_buf_putstr(SBuf *sb, GCstr *s)
return sb;
}
SBuf * LJ_FASTCALL lj_buf_putchar(SBuf *sb, int c)
{
char *p = lj_buf_more(sb, 1);
*p++ = (char)c;
setsbufP(sb, p);
return sb;
}
SBuf * LJ_FASTCALL lj_buf_putint(SBuf *sb, int32_t k)
{
setsbufP(sb, lj_str_bufint(lj_buf_more(sb, LJ_STR_INTBUF), k));