diff options
author | David Robillard <d@drobilla.net> | 2019-12-19 14:28:39 -0500 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2020-10-27 13:13:58 +0100 |
commit | 63b92951880e54ab0c06069486f0092a1ac3d337 (patch) | |
tree | 7e0b1453b353ff56e50ab5ba55fd07603a30861b | |
parent | 6c75e06ccf71c5ece8f32d5b78c01867fceb468d (diff) | |
download | serd-63b92951880e54ab0c06069486f0092a1ac3d337.tar.gz serd-63b92951880e54ab0c06069486f0092a1ac3d337.tar.bz2 serd-63b92951880e54ab0c06069486f0092a1ac3d337.zip |
Improve push_byte() performance
-rw-r--r-- | src/reader.h | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/reader.h b/src/reader.h index cfda66c8..aacc2ec8 100644 --- a/src/reader.h +++ b/src/reader.h @@ -148,14 +148,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*)reader->stack.buf)[reader->stack.size - 1] = (uint8_t)c; + ++reader->stack.size; ++node->n_bytes; - *(s - 1) = (uint8_t)c; - *s = '\0'; + return SERD_SUCCESS; } |