aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2019-12-19 14:28:39 -0500
committerDavid Robillard <d@drobilla.net>2019-12-19 20:55:14 -0500
commitfbfbcd96dee292ab97b66b505cc7449cfa422de9 (patch)
treeec370abf6af3630dbbef8a432749712c7dddc3b7
parent11bcffbf7728063edc8dcfcbdfba6e9b37e4c160 (diff)
downloadserd-fbfbcd96dee292ab97b66b505cc7449cfa422de9.tar.gz
serd-fbfbcd96dee292ab97b66b505cc7449cfa422de9.tar.bz2
serd-fbfbcd96dee292ab97b66b505cc7449cfa422de9.zip
Improve push_byte() performance
-rw-r--r--src/reader.h8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/reader.h b/src/reader.h
index 8dfed622..eb1a693c 100644
--- a/src/reader.h
+++ b/src/reader.h
@@ -154,14 +154,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;
}