1
0
forked from GitHub/gf-core

inline a number of functions in gu/seq.c. this has a noticeable effect on the parser's speed

This commit is contained in:
kr.angelov
2014-10-23 21:19:29 +00:00
parent 3aaeb7a156
commit aff68e7422
2 changed files with 55 additions and 87 deletions

View File

@@ -7,30 +7,6 @@
#include <malloc.h>
#endif
struct GuSeq {
size_t len;
uint8_t data[0];
};
struct GuBuf {
GuSeq* seq;
size_t elem_size;
size_t avail_len;
GuFinalizer fin;
};
size_t
gu_buf_length(GuBuf* buf)
{
return buf->seq->len;
}
size_t
gu_buf_avail(GuBuf* buf)
{
return buf->avail_len;
}
static void
gu_buf_fini(GuFinalizer* fin)
{
@@ -51,18 +27,6 @@ gu_make_buf(size_t elem_size, GuPool* pool)
return buf;
}
size_t
gu_seq_length(GuSeq* seq)
{
return seq->len;
}
void*
gu_seq_data(GuSeq* seq)
{
return seq->data;
}
static GuSeq gu_empty_seq_ = {0};
GuSeq*
@@ -129,18 +93,6 @@ gu_buf_require(GuBuf* buf, size_t req_len)
buf->avail_len = (real_size - sizeof(GuSeq)) / buf->elem_size;
}
void*
gu_buf_data(GuBuf* buf)
{
return &buf->seq->data;
}
GuSeq*
gu_buf_data_seq(GuBuf* buf)
{
return buf->seq;
}
void*
gu_buf_extend_n(GuBuf* buf, size_t n_elems)
{
@@ -151,12 +103,6 @@ gu_buf_extend_n(GuBuf* buf, size_t n_elems)
return &buf->seq->data[buf->elem_size * len];
}
void*
gu_buf_extend(GuBuf* buf)
{
return gu_buf_extend_n(buf, 1);
}
void
gu_buf_push_n(GuBuf* buf, const void* data, size_t n_elems)
{
@@ -173,18 +119,6 @@ gu_buf_trim_n(GuBuf* buf, size_t n_elems)
return &buf->seq->data[buf->elem_size * new_len];
}
const void*
gu_buf_trim(GuBuf* buf)
{
return gu_buf_trim_n(buf, 1);
}
void
gu_buf_flush(GuBuf* buf)
{
buf->seq->len = 0;
}
void
gu_buf_pop_n(GuBuf* buf, size_t n_elems, void* data_out)
{