Don't try to reinvent memcpy().

This commit is contained in:
Mike Pall 2013-05-22 22:57:18 +02:00
parent 82390d1f4f
commit 6f451c6445
2 changed files with 7 additions and 11 deletions

View File

@ -57,15 +57,7 @@ char * LJ_FASTCALL lj_buf_tmp(lua_State *L, MSize sz)
/* -- Low-level buffer put operations ------------------------------------- */
/* Write memory block to buffer. */
char *lj_buf_wmem(char *p, const void *q, MSize len)
{
const char *s = (const char *)q, *e = s + len;
while (s < e) *p++ = *s++;
return p;
}
SBuf * 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);

View File

@ -66,13 +66,17 @@ static LJ_AINLINE char *lj_buf_more(SBuf *sb, MSize sz)
}
/* Low-level buffer put operations */
LJ_FUNC char *lj_buf_wmem(char *p, const void *q, MSize len);
LJ_FUNC SBuf * lj_buf_putmem(SBuf *sb, const void *q, MSize len);
LJ_FUNC SBuf *lj_buf_putmem(SBuf *sb, const void *q, MSize len);
#if LJ_HASJIT
LJ_FUNC SBuf * LJ_FASTCALL lj_buf_putchar(SBuf *sb, int c);
#endif
LJ_FUNC SBuf * LJ_FASTCALL lj_buf_putstr(SBuf *sb, GCstr *s);
static LJ_AINLINE char *lj_buf_wmem(char *p, const void *q, MSize len)
{
return (char *)memcpy(p, q, len) + len;
}
static LJ_AINLINE void lj_buf_putb(SBuf *sb, int c)
{
char *p = lj_buf_more(sb, 1);