diff options
author | David Robillard <d@drobilla.net> | 2019-12-19 14:28:39 -0500 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2021-03-08 23:23:05 -0500 |
commit | fd4b39f477302ae5529aa63e78cb15b20ba04167 (patch) | |
tree | 5ee72067aa610eb6696c4b864f0ca91e40ff6799 | |
parent | fa593a6c62f47952069dffd644d0e5e777d0b5d1 (diff) | |
download | serd-fd4b39f477302ae5529aa63e78cb15b20ba04167.tar.gz serd-fd4b39f477302ae5529aa63e78cb15b20ba04167.tar.bz2 serd-fd4b39f477302ae5529aa63e78cb15b20ba04167.zip |
Improve push_byte() performance
-rw-r--r-- | src/reader.h | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/src/reader.h b/src/reader.h index 4810c8f4..8c8d45d5 100644 --- a/src/reader.h +++ b/src/reader.h @@ -159,15 +159,14 @@ push_byte(SerdReader* reader, SerdNode* node, const int c) assert(c != EOF); SERD_STACK_ASSERT_TOP(reader, node); - char* const s = (char*)serd_stack_push(&reader->stack, 1); - if (!s) { + if (reader->stack.size + 1 > reader->stack.buf_size) { return SERD_ERR_OVERFLOW; } - *(uint8_t*)(s - 1) = (uint8_t)c; - *s = '\0'; - + ((uint8_t*)reader->stack.buf)[reader->stack.size - 1] = (uint8_t)c; + ++reader->stack.size; ++node->n_bytes; + return SERD_SUCCESS; } |